Skip to content

Commit 467f622

Browse files
committed
Add new func for non-Job pods readiness helper for OCL
1 parent d7f6bf9 commit 467f622

File tree

1 file changed

+24
-0
lines changed
  • test/extended/util/compat_otp

1 file changed

+24
-0
lines changed

test/extended/util/compat_otp/pods.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,27 @@ func GetPodNameInHostedCluster(oc *exutil.CLI, namespace string, podLabel string
280280
daemonPod, err := oc.AsAdmin().AsGuestKubeconf().Run("get").Args(args...).Output()
281281
return strings.ReplaceAll(daemonPod, "'", ""), err
282282
}
283+
284+
// AssertAllNonJobPodsToBeReadyWithPollerParams assert all non-Job pods in NS are in ready state until timeout in a given namespace
285+
// Exclude transient Job pods ('job-name') from readiness: build Job pods are short‑lived and not expected to be Ready=True, so including them causes false failure
286+
// we validate the Job via logs/conditions separately, and this gate only asserts persistent controller pods (e.g., machine‑os‑builder) are Ready.
287+
func AssertAllNonJobPodsToBeReadyWithPollerParams(oc *exutil.CLI, namespace string, interval, timeout time.Duration) {
288+
err := wait.Poll(interval, timeout, func() (bool, error) {
289+
290+
// get the status flag for all pods
291+
// except the ones which are in Complete Status.
292+
// exclude pods that belong to Jobs (pods with 'job-name' label)
293+
// it use 'ne' operator which is only compatible with 4.10+ oc versions
294+
template := "'{{- range .items -}}{{- range .status.conditions -}}{{- if ne .reason \"PodCompleted\" -}}{{- if eq .type \"Ready\" -}}{{- .status}} {{\" \"}}{{- end -}}{{- end -}}{{- end -}}{{- end -}}'"
295+
stdout, err := oc.AsAdmin().Run("get").Args("pods", "-n", namespace, "-l", "!job-name").Template(template).Output()
296+
if err != nil {
297+
e2e.Logf("the err:%v, and try next round", err)
298+
return false, nil
299+
}
300+
if strings.Contains(stdout, "False") {
301+
return false, nil
302+
}
303+
return true, nil
304+
})
305+
AssertWaitPollNoErr(err, fmt.Sprintf("Some Pods are not ready in NS %s (excluding Job pods)!", namespace))
306+
}

0 commit comments

Comments
 (0)