Skip to content

Commit 57b45b4

Browse files
committed
Retry on brief apiserver unavailability
1 parent 9514c30 commit 57b45b4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,21 @@ func snapshotOcAdmUpgradeStatus(ch chan *snapshot) {
5858
// how to do pass that to exutil.NewCLI* or if it is even possible. It seems to work this way though.
5959
oc := exutil.NewCLIWithoutNamespace("adm-upgrade-status").AsAdmin()
6060
now := time.Now()
61-
// TODO: Consider retrying on brief apiserver unavailability
62-
cmd := oc.Run("adm", "upgrade", "status").EnvVar("OC_ENABLE_CMD_UPGRADE_STATUS", "true")
63-
out, err := cmd.Output()
61+
62+
var out string
63+
var err error
64+
// retry on brief apiserver unavailability
65+
if errWait := wait.PollUntilContextTimeout(context.Background(), 10*time.Second, 2*time.Minute, true, func(context.Context) (bool, error) {
66+
cmd := oc.Run("adm", "upgrade", "status").EnvVar("OC_ENABLE_CMD_UPGRADE_STATUS", "true")
67+
out, err = cmd.Output()
68+
if err != nil {
69+
return false, nil
70+
}
71+
return true, nil
72+
}); errWait != nil {
73+
out = ""
74+
err = errWait
75+
}
6476
ch <- &snapshot{when: now, out: out, err: err}
6577
}
6678

0 commit comments

Comments
 (0)