Skip to content

Commit 02464a4

Browse files
Merge pull request #30151 from petr-muller/ota-1581-better-errs
NO-JIRA: `oc adm upgrade status`: Record err and outputs
2 parents 6d741de + 5a54c99 commit 02464a4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/monitortests/cli/adm_upgrade/status/monitortest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,26 @@ func snapshotOcAdmUpgradeStatus(ch chan *snapshot) {
102102
oc := exutil.NewCLIWithoutNamespace("adm-upgrade-status").AsAdmin()
103103
now := time.Now()
104104

105+
var attempts int
106+
var attemptRecorder strings.Builder
107+
105108
var out string
106109
var err error
107110
// retry on brief apiserver unavailability
108111
if errWait := wait.PollUntilContextTimeout(context.Background(), 10*time.Second, 2*time.Minute, true, func(context.Context) (bool, error) {
112+
attempts++
109113
cmd := oc.Run("adm", "upgrade", "status", "--details=all")
110114
out, err = cmd.Output()
111115
if err != nil {
116+
attemptRecorder.WriteString(fmt.Sprintf("Attempt #%d failed: %s\nOutput:%s\n", attempts, err.Error(), out))
112117
return false, nil
113118
}
114119
return true, nil
115120
}); errWait != nil {
116121
out = ""
117-
err = errWait
122+
err = fmt.Errorf("failed to run oc adm upgrade status after %d attempts: %w\nrecorded attempts and outputs:\n%s", attempts, errWait, attemptRecorder.String())
118123
}
124+
119125
ch <- &snapshot{when: now, out: out, err: err}
120126
}
121127

0 commit comments

Comments
 (0)