diff --git a/controllers/apps/v2beta1/add_emqx_core.go b/controllers/apps/v2beta1/add_emqx_core.go index ea1f000b0..953ddeea7 100644 --- a/controllers/apps/v2beta1/add_emqx_core.go +++ b/controllers/apps/v2beta1/add_emqx_core.go @@ -60,6 +60,9 @@ func (a *addCore) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, _ i logger := log.FromContext(ctx) logger.V(1).Info("got different statefulSet for EMQX core nodes, will update statefulSet", "patch", string(patchResult.Patch)) + preSts.SetResourceVersion(storageSts.GetResourceVersion()) + preSts.SetCreationTimestamp(storageSts.GetCreationTimestamp()) + preSts.SetManagedFields(storageSts.GetManagedFields()) if err := a.Handler.Update(preSts); err != nil { return subResult{err: emperror.Wrap(err, "failed to update statefulSet")} } diff --git a/controllers/apps/v2beta1/add_emqx_core_suite_test.go b/controllers/apps/v2beta1/add_emqx_core_suite_test.go index 8572492f2..78ebacb61 100644 --- a/controllers/apps/v2beta1/add_emqx_core_suite_test.go +++ b/controllers/apps/v2beta1/add_emqx_core_suite_test.go @@ -80,6 +80,12 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() { sts := list.Items[0].DeepCopy() sts.Status.Replicas = 2 Expect(k8sClient.Status().Update(ctx, sts)).Should(Succeed()) + Eventually(func() *appsv1.StatefulSet { + _ = k8sClient.Get(ctx, client.ObjectKeyFromObject(sts), sts) + return sts + }).WithTimeout(timeout).WithPolling(interval).Should( + WithTransform(func(s *appsv1.StatefulSet) int32 { return s.Status.Replicas }, Equal(int32(2))), + ) instance.Status.CoreNodesStatus.UpdateRevision = sts.Labels[appsv2beta1.PodTemplateHashLabelKey] instance.Spec.CoreTemplate.Spec.Replicas = pointer.Int32(4) diff --git a/controllers/apps/v2beta1/add_emqx_repl.go b/controllers/apps/v2beta1/add_emqx_repl.go index 8fd1bb54c..d9d3f8fb3 100644 --- a/controllers/apps/v2beta1/add_emqx_repl.go +++ b/controllers/apps/v2beta1/add_emqx_repl.go @@ -66,6 +66,9 @@ func (a *addRepl) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, _ i logger := log.FromContext(ctx) logger.V(1).Info("got different statefulSet for EMQX core nodes, will update statefulSet", "patch", string(patchResult.Patch)) + preRs.SetResourceVersion(storageRs.GetResourceVersion()) + preRs.SetCreationTimestamp(storageRs.GetCreationTimestamp()) + preRs.SetManagedFields(storageRs.GetManagedFields()) if err := a.Handler.Update(preRs); err != nil { return subResult{err: emperror.Wrap(err, "failed to update replicaSet")} } diff --git a/controllers/apps/v2beta1/suite_test.go b/controllers/apps/v2beta1/suite_test.go index 994197eb3..5811c07b3 100644 --- a/controllers/apps/v2beta1/suite_test.go +++ b/controllers/apps/v2beta1/suite_test.go @@ -76,8 +76,8 @@ func TestAPIs(t *testing.T) { } var _ = BeforeSuite(func() { - timeout = time.Second * 3 - interval = time.Millisecond * 250 + timeout = time.Second * 10 + interval = time.Millisecond * 500 ctx = context.TODO() emqx.Default() diff --git a/e2e/v2beta1/e2e_test.go b/e2e/v2beta1/e2e_test.go index 2db512fe1..7fea416f3 100644 --- a/e2e/v2beta1/e2e_test.go +++ b/e2e/v2beta1/e2e_test.go @@ -284,7 +284,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { }) }) - Context("replicant template is not nil", func() { + Context("replicant template is not nil", Label("debug"), func() { JustBeforeEach(func() { Expect(k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance)).Should(Succeed()) diff --git a/e2e/v2beta1/suite_test.go b/e2e/v2beta1/suite_test.go index 01c590ed2..2d3f123dc 100644 --- a/e2e/v2beta1/suite_test.go +++ b/e2e/v2beta1/suite_test.go @@ -69,7 +69,7 @@ func TestAPIs(t *testing.T) { var _ = BeforeSuite(func() { emqx = genEMQX() - timeout = time.Minute * 5 + timeout = time.Minute * 10 interval = time.Second * 1 Expect(os.Setenv("USE_EXISTING_CLUSTER", "true")).To(Succeed())