diff --git a/controllers/apps/v2beta1/update_emqx_status.go b/controllers/apps/v2beta1/update_emqx_status.go index fc0575f2..ff0360e7 100644 --- a/controllers/apps/v2beta1/update_emqx_status.go +++ b/controllers/apps/v2beta1/update_emqx_status.go @@ -23,6 +23,9 @@ type updateStatus struct { func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) subResult { if instance.Status.CoreNodesStatus == nil { instance.Status.CoreNodesStatus = &appsv2beta1.EMQXNodesStatus{} + if err := u.Client.Status().Update(ctx, instance); err != nil { + return subResult{err: emperror.Wrap(err, "failed to update status")} + } } instance.Status.CoreNodesStatus.Replicas = *instance.Spec.CoreTemplate.Spec.Replicas if instance.Status.CoreNodesStatus.UpdateRevision != "" && instance.Status.CoreNodesStatus.CurrentRevision == "" { @@ -32,6 +35,9 @@ func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instan if instance.Spec.ReplicantTemplate != nil { if instance.Status.ReplicantNodesStatus == nil { instance.Status.ReplicantNodesStatus = &appsv2beta1.EMQXNodesStatus{} + if err := u.Client.Status().Update(ctx, instance); err != nil { + return subResult{err: emperror.Wrap(err, "failed to update status")} + } } instance.Status.ReplicantNodesStatus.Replicas = *instance.Spec.ReplicantTemplate.Spec.Replicas if instance.Status.ReplicantNodesStatus.UpdateRevision != "" && instance.Status.ReplicantNodesStatus.CurrentRevision == "" {