From 57a1634b42b8712f25c0e6a66d9037222cdcc06a Mon Sep 17 00:00:00 2001 From: Derek Wang Date: Tue, 21 Sep 2021 10:40:26 -0700 Subject: [PATCH] fix: not upating status even replicas changed (#366) Signed-off-by: Derek Wang --- manager/controllers/step_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/controllers/step_controller.go b/manager/controllers/step_controller.go index a1832b87..e70c7c8c 100644 --- a/manager/controllers/step_controller.go +++ b/manager/controllers/step_controller.go @@ -129,6 +129,7 @@ func (r *StepReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. desiredReplicas := int(step.Spec.Replicas) + oldStatus := step.Status.DeepCopy() if currentReplicas != desiredReplicas || step.Status.Selector == "" { log.Info("replicas changed", "currentReplicas", currentReplicas, "desiredReplicas", desiredReplicas) step.Status.Replicas = uint32(desiredReplicas) @@ -138,7 +139,6 @@ func (r *StepReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. selector, _ := labels.Parse(dfv1.KeyPipelineName + "=" + pipelineName + "," + dfv1.KeyStepName + "=" + stepName) hash := util.MustHash(hash{runnerImage, step.Spec.WithOutReplicas()}) // we must remove data (e.g. replicas) which does not change the pod, otherwise it would cause the pod to be re-created all the time - oldStatus := step.Status.DeepCopy() step.Status.Phase, step.Status.Reason, step.Status.Message = dfv1.StepUnknown, "", "" step.Status.Selector = selector.String()