From 19deade0610d0cde89af67691ae9f18eeb5988e0 Mon Sep 17 00:00:00 2001 From: Kent Rancourt Date: Thu, 21 Dec 2023 19:42:19 -0500 Subject: [PATCH] fix(controller): fix stage getting stuck in verifying phase if no verification process is defined (#1321) Signed-off-by: Kent Rancourt --- internal/controller/stages/stages.go | 7 +++++++ internal/controller/stages/stages_test.go | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/controller/stages/stages.go b/internal/controller/stages/stages.go index a71c043cf..1e0cf9b19 100644 --- a/internal/controller/stages/stages.go +++ b/internal/controller/stages/stages.go @@ -575,6 +575,13 @@ func (r *reconciler) syncNormalStage( freightLogger.Debug("Stage health deemed not applicable") } + // If the Stage is healthy and no verification process is defined, then the + // Stage should transition to the Steady phase. + if (status.Health == nil || status.Health.Status == kargoapi.HealthStateHealthy) && + stage.Spec.Verification == nil && status.Phase == kargoapi.StagePhaseVerifying { + status.Phase = kargoapi.StagePhaseSteady + } + // Initiate or follow-up on verification if required if status.Phase == kargoapi.StagePhaseVerifying && stage.Spec.Verification != nil { if status.CurrentFreight.VerificationInfo == nil { diff --git a/internal/controller/stages/stages_test.go b/internal/controller/stages/stages_test.go index 37c6503ac..491507014 100644 --- a/internal/controller/stages/stages_test.go +++ b/internal/controller/stages/stages_test.go @@ -421,7 +421,11 @@ func TestSyncNormalStage(t *testing.T) { require.Error(t, err) require.Contains(t, err.Error(), "something went wrong") require.Contains(t, err.Error(), "error marking Freight") - // Status should be returned unchanged + // Since no verification process was defined and the Stage is healthy, + // the Stage should have transitioned to a Steady phase. + require.Equal(t, kargoapi.StagePhaseSteady, newStatus.Phase) + // Status should be otherwise unchanged + newStatus.Phase = initialStatus.Phase require.Equal(t, initialStatus, newStatus) }, },