diff --git a/module-controller/internal/controller/moduledeployment_controller.go b/module-controller/internal/controller/moduledeployment_controller.go index c032b9781..9cc913d56 100644 --- a/module-controller/internal/controller/moduledeployment_controller.go +++ b/module-controller/internal/controller/moduledeployment_controller.go @@ -214,10 +214,13 @@ func handleInitModuleDeployment(moduleDeployment *v1alpha1.ModuleDeployment, new ) batchCount := moduleDeployment.Spec.OperationStrategy.BatchCount + useBeta := moduleDeployment.Spec.OperationStrategy.UseBeta if batchCount <= 0 { realBatchCount = 1 } else if int32(math.Abs(float64(deltaReplicas))) < batchCount { realBatchCount = int32(math.Abs(float64(deltaReplicas))) + } else if useBeta && moduleDeployment.Spec.Replicas-1 > 1 { + realBatchCount = batchCount + 1 } else { realBatchCount = batchCount } diff --git a/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go b/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go index 42587249a..4933e6532 100644 --- a/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go +++ b/module-controller/internal/controller/moduledeployment_controller_operation_strategy_suit_test.go @@ -29,6 +29,7 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { deployment := prepareDeployment(namespace) moduleDeploymentName := "module-deployment-test-demo" moduleDeployment := utils.PrepareModuleDeployment(namespace, moduleDeploymentName) + moduleDeployment.Spec.OperationStrategy.BatchCount = 4 pod := preparePod(namespace, "fake-pod-1") Context("create module deployment", func() { It("prepare deployment and pod", func() { @@ -695,7 +696,7 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { It("2. check if use Beta strategy", func() { Eventually(func() error { return checkModuleDeploymentReplicas(nn, 1) - }) + }, timeout, interval).Should(Succeed()) }) It("3. clean environment", func() { @@ -745,7 +746,7 @@ var _ = Describe("ModuleDeployment Controller OperationStrategy Test", func() { It("2. check if use Beta strategy", func() { Eventually(func() error { return checkModuleDeploymentReplicas(nn, 1) - }) + }, timeout, interval).Should(Succeed()) }) It("3. clean environment", func() {