From 90ca505bb027ec9d1ae79c728d6af2a86110edae Mon Sep 17 00:00:00 2001 From: Derek Wang Date: Fri, 17 Mar 2023 15:36:24 -0700 Subject: [PATCH] fix: do not update status.replicas until pod operation succeeds (#620) Signed-off-by: Derek Wang --- pkg/reconciler/vertex/controller.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/reconciler/vertex/controller.go b/pkg/reconciler/vertex/controller.go index 051e52446..e8abc669a 100644 --- a/pkg/reconciler/vertex/controller.go +++ b/pkg/reconciler/vertex/controller.go @@ -156,15 +156,6 @@ func (r *vertexReconciler) reconcile(ctx context.Context, vertex *dfv1.Vertex) ( } } - currentReplicas := int(vertex.Status.Replicas) - if currentReplicas != desiredReplicas || vertex.Status.Selector == "" { - log.Infow("Replicas changed", "currentReplicas", currentReplicas, "desiredReplicas", desiredReplicas) - vertex.Status.Replicas = uint32(desiredReplicas) - vertex.Status.LastScaledAt = metav1.Time{Time: time.Now()} - } - selector, _ := labels.Parse(dfv1.KeyPipelineName + "=" + vertex.Spec.PipelineName + "," + dfv1.KeyVertexName + "=" + vertex.Spec.Name) - vertex.Status.Selector = selector.String() - pipeline := &dfv1.Pipeline{} if err := r.client.Get(ctx, types.NamespacedName{Namespace: vertex.Namespace, Name: vertex.Spec.PipelineName}, pipeline); err != nil { log.Errorw("Failed to get pipeline object", zap.Error(err)) @@ -250,6 +241,15 @@ func (r *vertexReconciler) reconcile(ctx context.Context, vertex *dfv1.Vertex) ( } } + currentReplicas := int(vertex.Status.Replicas) + if currentReplicas != desiredReplicas || vertex.Status.Selector == "" { + log.Infow("Replicas changed", "currentReplicas", currentReplicas, "desiredReplicas", desiredReplicas) + vertex.Status.Replicas = uint32(desiredReplicas) + vertex.Status.LastScaledAt = metav1.Time{Time: time.Now()} + } + selector, _ := labels.Parse(dfv1.KeyPipelineName + "=" + vertex.Spec.PipelineName + "," + dfv1.KeyVertexName + "=" + vertex.Spec.Name) + vertex.Status.Selector = selector.String() + // create services existingSvcs, err := r.findExistingServices(ctx, vertex) if err != nil {