Skip to content
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
7 changes: 6 additions & 1 deletion pkg/ai/context/summary_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,12 @@ func summarizeArgoAnalysisRun(obj *unstructured.Unstructured) *ResourceSummary {
switch {
case len(failing) > 0:
s.Issue = strings.Join(failing, "; ")
default:
// Argo writes status.message only when a run finishes, and a finished run
// can be fine: Argo stops a run once the Rollout no longer needs it (a
// canary completing with background analysis, a newer revision, an abort,
// a promote-full, a fast rollback), and that run ends Successful with
// "Run Terminated". So the message is an issue only on a bad verdict.
case s.Status == "Failed", s.Status == "Error", s.Status == "Inconclusive":
s.Issue, _, _ = unstructured.NestedString(obj.Object, "status", "message")
}

Expand Down
44 changes: 44 additions & 0 deletions pkg/ai/context/summary_rollout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,47 @@ func TestSummarizeArgoAnalysisRun_AbsentDryRunStillCounts(t *testing.T) {
t.Fatalf("issue = %q, want the failing metric named", summary.Issue)
}
}

func TestSummarizeArgoAnalysisRun_MessageIsOnlyAnIssueOnABadVerdict(t *testing.T) {
tests := []struct {
name string
status map[string]any
wantIssue string
}{
{
name: "failed run with no scored metric falls back to the message",
status: map[string]any{"phase": "Failed", "message": "Run Failed"},
wantIssue: "Run Failed",
},
{
name: "errored run falls back to the message",
status: map[string]any{"phase": "Error", "message": `Unable to resolve metric arguments: secrets "db-creds" not found`},
wantIssue: "Unable to resolve metric arguments",
},
{
name: "inconclusive run falls back to the message",
status: map[string]any{"phase": "Inconclusive", "message": "Metric assessed Inconclusive"},
wantIssue: "Metric assessed Inconclusive",
},
{
name: "run stopped by the controller is not an issue",
status: map[string]any{"phase": "Successful", "message": "Run Terminated"},
wantIssue: "",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
summary := summarizeUnstructured(argoObj("AnalysisRun", nil, nil, tt.status))
if tt.wantIssue == "" {
if summary.Issue != "" {
t.Fatalf("issue = %q, want empty", summary.Issue)
}
return
}
if !strings.Contains(summary.Issue, tt.wantIssue) {
t.Fatalf("issue = %q, want it to contain %q", summary.Issue, tt.wantIssue)
}
})
}
}
Loading