diff --git a/utils/analysis/helpers.go b/utils/analysis/helpers.go index 77583136af..caedeb472c 100644 --- a/utils/analysis/helpers.go +++ b/utils/analysis/helpers.go @@ -85,11 +85,15 @@ func IsTerminating(run *v1alpha1.AnalysisRun) bool { return true } for _, res := range run.Status.MetricResults { + // If this metric is running in the dryRun mode then we don't care about the failures and hence the terminal + // decision shouldn't be affected. + if res.DryRun { + continue + } + switch res.Phase { case v1alpha1.AnalysisPhaseFailed, v1alpha1.AnalysisPhaseError, v1alpha1.AnalysisPhaseInconclusive: - // If this metric is running in the dryRun mode then we don't care about the failures and hence the terminal - // decision shouldn't be affected. - return !res.DryRun + return true } } return false diff --git a/utils/analysis/helpers_test.go b/utils/analysis/helpers_test.go index f9baf89f14..3fbefadce4 100644 --- a/utils/analysis/helpers_test.go +++ b/utils/analysis/helpers_test.go @@ -67,6 +67,10 @@ func TestIsFastFailTerminating(t *testing.T) { Phase: v1alpha1.AnalysisPhaseRunning, DryRun: true, }, + { + Name: "yet-another-metric", + Phase: v1alpha1.AnalysisPhaseRunning, + }, }, }, } @@ -78,6 +82,11 @@ func TestIsFastFailTerminating(t *testing.T) { dryRunMetricResult.Phase = v1alpha1.AnalysisPhaseError run.Status.MetricResults[2] = dryRunMetricResult assert.False(t, IsTerminating(run)) + // Verify that a wet run metric failure/error which is executed after a dry-run metric results in terminal decision. + yetAnotherMetric := run.Status.MetricResults[3] + yetAnotherMetric.Phase = v1alpha1.AnalysisPhaseError + run.Status.MetricResults[3] = yetAnotherMetric + assert.True(t, IsTerminating(run)) // Verify that a wet run metric failure/error results in terminal decision. successRate.Phase = v1alpha1.AnalysisPhaseError run.Status.MetricResults[1] = successRate