Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(analysis): Fix Analysis Terminal Decision For Dry-Run Metrics #2399

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions utils/analysis/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions utils/analysis/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func TestIsFastFailTerminating(t *testing.T) {
Phase: v1alpha1.AnalysisPhaseRunning,
DryRun: true,
},
{
Name: "yet-another-metric",
Phase: v1alpha1.AnalysisPhaseRunning,
},
},
},
}
Expand All @@ -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
Expand Down