diff --git a/lifecycle-operator/controllers/common/phasehandler.go b/lifecycle-operator/controllers/common/phasehandler.go index 3ca5ce5c46..50460ca38d 100644 --- a/lifecycle-operator/controllers/common/phasehandler.go +++ b/lifecycle-operator/controllers/common/phasehandler.go @@ -94,7 +94,8 @@ func (r PhaseHandler) handleCompletedPhase(state apicommon.KeptnState, piWrapper return &PhaseResult{Continue: false, Result: ctrl.Result{}}, nil } - piWrapper.SetState(apicommon.StateSucceeded) + // end the current phase do not set the overall state of the whole object to Succeeded here, as this can cause + // premature progression of reconcile objects that depend on the completion of another spanPhaseTrace.AddEvent(phase.LongName + " has succeeded") spanPhaseTrace.SetStatus(codes.Ok, "Succeeded") spanPhaseTrace.End() diff --git a/lifecycle-operator/controllers/common/phasehandler_test.go b/lifecycle-operator/controllers/common/phasehandler_test.go index afcc5cdc51..51bc1d732d 100644 --- a/lifecycle-operator/controllers/common/phasehandler_test.go +++ b/lifecycle-operator/controllers/common/phasehandler_test.go @@ -152,7 +152,7 @@ func TestPhaseHandler(t *testing.T) { wantErr: nil, wantObject: &v1alpha3.KeptnAppVersion{ Status: v1alpha3.KeptnAppVersionStatus{ - Status: apicommon.StateSucceeded, + Status: apicommon.StatePending, CurrentPhase: apicommon.PhaseAppDeployment.ShortName, }, }, diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go index f6e8bf063e..4402effdea 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go @@ -160,25 +160,21 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ } } - err = r.Client.Status().Update(ctx, appVersion) - if err != nil { - span.SetStatus(codes.Error, err.Error()) - return ctrl.Result{Requeue: true}, err - } // AppVersion is completed at this place - - return r.finishKeptnAppVersionReconcile(ctx, appVersion, spanAppTrace) + return r.finishKeptnAppVersionReconcile(ctx, appVersion, spanAppTrace, span) } -func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.Context, appVersion *klcv1alpha3.KeptnAppVersion, spanAppTrace trace.Span) (ctrl.Result, error) { +func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.Context, appVersion *klcv1alpha3.KeptnAppVersion, spanAppTrace, span trace.Span) (ctrl.Result, error) { if !appVersion.IsEndTimeSet() { appVersion.Status.CurrentPhase = apicommon.PhaseCompleted.ShortName + appVersion.Status.Status = apicommon.StateSucceeded appVersion.SetEndTime() } err := r.Client.Status().Update(ctx, appVersion) if err != nil { + span.SetStatus(codes.Error, err.Error()) return ctrl.Result{Requeue: true}, err }