Count repeated report write failures once

This commit is contained in:
2026-11-17 12:52:34 +00:00
parent cc0a420722
commit b3ed91d593
3 changed files with 48 additions and 1 deletions

View File

@@ -329,6 +329,7 @@ func (s *OutputSession) publishReports(ctx context.Context, reports ReportBundle
var rendered reportState
var written [3]reportState
var attemptedFailed [3]bool
failureIndexes := [3]int{-1, -1, -1}
refresh := func() bool {
state := observed()
if state == rendered {
@@ -359,7 +360,14 @@ func (s *OutputSession) publishReports(ctx context.Context, reports ReportBundle
attemptedFailed[i] = true
}
if err := s.replace(writeCtx, s.reportDestinations[i], bundleParts(reports)[i]); err != nil {
failures = append(failures, FileFailure{Path: s.reports[i], Phase: phase, Kind: kind, Err: err})
// A retry adds a cause to the same delivery failure. Reports count
// the failed destination, so the rendered facts stay current.
if previous := failureIndexes[i]; previous >= 0 {
failures[previous].Err = errors.Join(failures[previous].Err, err)
} else {
failureIndexes[i] = len(failures)
failures = append(failures, FileFailure{Path: s.reports[i], Phase: phase, Kind: kind, Err: err})
}
} else {
written[i] = rendered
}