Skip to content

Commit

Permalink
fix(controller): fix stage getting stuck in verifying phase if no ver…
Browse files Browse the repository at this point in the history
…ification process is defined (#1321)

Signed-off-by: Kent Rancourt <[email protected]>
  • Loading branch information
krancour authored Dec 22, 2023
1 parent 601a437 commit 19deade
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/controller/stages/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion internal/controller/stages/stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand Down

0 comments on commit 19deade

Please sign in to comment.