Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add batch install biz #29

Merged
merged 11 commits into from
Jan 7, 2025
4 changes: 4 additions & 0 deletions common/model/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
CommandInstallBiz = "installBiz"
// CommandUnInstallBiz uninstalls a business module
CommandUnInstallBiz = "uninstallBiz"
// CommandBatchInstallBiz batch install biz, since koupleless-runtime 1.4.1
CommandBatchInstallBiz = "batchInstallBiz"
)

// MQTT topic patterns for base communication
Expand All @@ -65,6 +67,8 @@ const (
BaseAllBizTopic = "koupleless_%s/%s/base/biz"
// BaseBizOperationResponseTopic for business operation responses, p2p mode
BaseBizOperationResponseTopic = "koupleless_%s/%s/base/bizOperation"
// BaseBatchInstallBizResponseTopic for response of batch install biz, p2p mode, since koupleless-runtime 1.4.1
BaseBatchInstallBizResponseTopic = "koupleless_%s/%s/base/batchInstallBizResponse"
// BaseBaselineResponseTopic for baseline responses, p2p mode
BaseBaselineResponseTopic = "koupleless_%s/%s/base/baseline"
)
Expand Down
13 changes: 9 additions & 4 deletions common/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@

// BizOperationResponse represents the response from a business operation
type BizOperationResponse struct {
Command string `json:"command"` // Operation command executed
BizName string `json:"bizName"` // ClusterName of the business
BizVersion string `json:"bizVersion"` // Version of the business
Response ark_service.ArkResponse `json:"response"` // Response from ark service
Command string `json:"command"` // Operation command executed
BizName string `json:"bizName"` // ClusterName of the business
BizVersion string `json:"bizVersion"` // Version of the business
Response ark_service.ArkResponse[ark.ArkResponseData] `json:"response"` // Response from ark service
}

type BatchInstallBizResponse struct {
Command string `json:"command"` // Operation command executed
Response ark_service.ArkResponse[ark.ArkBatchInstallResponse] `json:"response"` // Response from ark service
Comment on lines +40 to +42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Dependency issue confirmed - ArkBatchInstallResponse type not available

The search results show that the code is using github.com/koupleless/arkctl v0.2.3, but the ArkBatchInstallResponse type is not found in the current codebase. However, the type is being used in multiple locations:

  • common/model/model.go: In the struct definition
  • module_tunnels/koupleless_mqtt_tunnel/mqtt_tunnel.go: Being used to process response data

Since:

  1. The type is not found in the current version of dependencies
  2. The code is already using this type in multiple places
  3. The PR description mentions a dependency on Feat: add batch install biz handler runtime#231

This confirms that this PR has an unmet dependency that needs to be resolved first.

Please:

  1. Wait for Feat: add batch install biz handler runtime#231 to be merged
  2. Update the dependency version in go.mod to include the new type
  3. Document the structure of ArkBatchInstallResponse in your code comments
🔗 Analysis chain

Verify dependency and add documentation for batch install response.

The pipeline failure indicates that ark.ArkBatchInstallResponse is undefined. This is likely because this PR depends on koupleless/runtime#231.

Please ensure:

  1. The dependency PR (Feat: add batch install biz handler runtime#231) is merged first
  2. Add documentation describing the structure and fields of ArkBatchInstallResponse

Run this script to verify the dependency:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the required type is defined in the runtime repository
# Expected: Find the type definition in the dependent PR

# Check if the type exists in current branch
rg -g '*.go' "type ArkBatchInstallResponse"

# Check go.mod for runtime dependency version
cat go.mod | grep "koupleless/runtime"

Length of output: 84


Script:

#!/bin/bash
# Let's try a broader search to understand the context better

# Search for any reference to BatchInstallResponse
rg -g '*.go' "BatchInstallResponse"

# Check for ark service related types
rg -g '*.go' "type.*Response.*ark"

# Look for imports related to ark
rg -g '*.go' 'import.*".*ark.*"'

# Check go.mod content to understand dependencies
cat go.mod

Length of output: 4321

🧰 Tools
🪛 GitHub Check: unit-test

[failure] 42-42:
undefined: ark.ArkBatchInstallResponse

🪛 GitHub Actions: lvjing2 pushed module-controller code

[error] 42-42: undefined: ark.ArkBatchInstallResponse - Type reference not found

}

Check failure on line 42 in common/model/model.go

View workflow job for this annotation

GitHub Actions / unit-test

undefined: ark.ArkBatchInstallResponse

// QueryBaselineRequest is the request parameters of query baseline func
// Used to query baseline configuration with filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type ModuleDeploymentController struct {

cache cache.Cache // The cache for storing and retrieving Kubernetes objects.

runtimeStorage *RuntimeInfoStore // Storage for runtime information about deployments and nodes.

updateToken chan interface{} // A channel for signaling updates.
}

Expand All @@ -51,9 +49,8 @@ func (moduleDeploymentController *ModuleDeploymentController) Reconcile(ctx cont
// NewModuleDeploymentController creates a new instance of the controller.
func NewModuleDeploymentController(env string) (*ModuleDeploymentController, error) {
return &ModuleDeploymentController{
env: env,
runtimeStorage: NewRuntimeInfoStore(),
updateToken: make(chan interface{}, 1),
env: env,
updateToken: make(chan interface{}, 1),
}, nil
}

Expand Down Expand Up @@ -100,25 +97,17 @@ func (moduleDeploymentController *ModuleDeploymentController) SetupWithManager(c
return
}

for _, vnode := range vnodeList.Items {
// no deployment, just add
moduleDeploymentController.runtimeStorage.PutNode(vnode.DeepCopy())
}

// init deployments
depList := &appsv1.DeploymentList{}
err = moduleDeploymentController.cache.List(ctx, depList, &client.ListOptions{
LabelSelector: deploymentSelector,
})

if err != nil {
err = errors.New("failed to list deployments")
return
}

for _, deployment := range depList.Items {
moduleDeploymentController.runtimeStorage.PutDeployment(deployment)
}

moduleDeploymentController.updateDeploymentReplicas(ctx, depList.Items)
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@ package module_deployment_controller

import (
"context"
"github.com/stretchr/testify/assert"
"testing"
)

func TestDeploymentHandler(t *testing.T) {
c := &ModuleDeploymentController{
runtimeStorage: NewRuntimeInfoStore(),
updateToken: make(chan interface{}),
updateToken: make(chan interface{}),
}

ctx := context.Background()
c.deploymentAddHandler(ctx, nil)

assert.Equal(t, 0, len(c.runtimeStorage.peerDeploymentMap))

c.deploymentUpdateHandler(ctx, nil, nil)

assert.Equal(t, 0, len(c.runtimeStorage.peerDeploymentMap))
}
Loading
Loading