Skip to content

Commit

Permalink
fix: fix i/o timeout when request emqx API
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Aug 8, 2023
1 parent 9ddbfe0 commit 580aac1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions controllers/apps/v2beta1/add_emqx_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")}
}
Expand Down
6 changes: 6 additions & 0 deletions controllers/apps/v2beta1/add_emqx_core_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions controllers/apps/v2beta1/add_emqx_repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")}
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/apps/v2beta1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion e2e/v2beta1/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion e2e/v2beta1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 580aac1

Please sign in to comment.