Skip to content

Commit 7a56cf0

Browse files
Merge pull request #5270 from pablintino/ocpbugs-61016
OCPBUGS-61016: Fix wait failure on MCO pods
2 parents cc2f713 + e516665 commit 7a56cf0

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

test/extended/mco_ocb.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ func ValidateSuccessfulMOSC(mosc *MachineOSConfig, checkers []Checker) {
302302
o.Eventually(mOSBuilder.Get, "2m", "30s").WithArguments(`{.status.availableReplicas}`).Should(o.Equal("1"),
303303
"The machine-os-builder deployment was created but the available number of replicas is not the expected one")
304304

305-
exutil.AssertAllPodsToBeReady(mosc.GetOC(), MachineConfigNamespace)
305+
// Ensure all pods are running
306+
// Do not consider pods created by jobs, as the build pod uses an init container
307+
// to build that takes time to be ready and its configuration will be asserted later
308+
exutil.AssertAllPodsToBeReadyWithSelector(mosc.GetOC(), MachineConfigNamespace, "!batch.kubernetes.io/job-name")
306309
logger.Infof("OK!\n")
307310

308311
exutil.By("Check that the machine-os-builder is using leader election without failing")

test/extended/util/pods.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,18 @@ func GetPodName(oc *CLI, namespace, podLabel, node string) (string, error) {
9696

9797
// AssertAllPodsToBeReadyWithPollerParams assert all pods in NS are in ready state until timeout in a given namespace
9898
// Pros: allow user to customize poller parameters
99-
func AssertAllPodsToBeReadyWithPollerParams(oc *CLI, namespace string, interval, timeout time.Duration) {
99+
func AssertAllPodsToBeReadyWithPollerParams(oc *CLI, namespace string, interval, timeout time.Duration, selector string) {
100100
err := wait.PollUntilContextTimeout(context.Background(), interval, timeout, false, func(_ context.Context) (bool, error) {
101101

102102
// get the status flag for all pods
103103
// except the ones which are in Complete Status.
104104
// it use 'ne' operator which is only compatible with 4.10+ oc versions
105105
template := "'{{- range .items -}}{{- range .status.conditions -}}{{- if ne .reason \"PodCompleted\" -}}{{- if eq .type \"Ready\" -}}{{- .status}} {{\" \"}}{{- end -}}{{- end -}}{{- end -}}{{- end -}}'"
106-
stdout, err := oc.AsAdmin().Run("get").Args("pods", "-n", namespace).Template(template).Output()
106+
baseArgs := []string{"pods", "-n", namespace}
107+
if selector != "" {
108+
baseArgs = append(baseArgs, "-l", selector)
109+
}
110+
stdout, err := oc.AsAdmin().Run("get").Args(baseArgs...).Template(template).Output()
107111
if err != nil {
108112
e2e.Logf("the err:%v, and try next round", err)
109113
return false, nil
@@ -118,5 +122,11 @@ func AssertAllPodsToBeReadyWithPollerParams(oc *CLI, namespace string, interval,
118122

119123
// AssertAllPodsToBeReady assert all pods in NS are in ready state until timeout in a given namespace
120124
func AssertAllPodsToBeReady(oc *CLI, namespace string) {
121-
AssertAllPodsToBeReadyWithPollerParams(oc, namespace, 10*time.Second, 4*time.Minute)
125+
AssertAllPodsToBeReadyWithPollerParams(oc, namespace, 10*time.Second, 4*time.Minute, "")
126+
}
127+
128+
// AssertAllPodsToBeReadyWithSelector assert all pods in NS are in ready state until timeout in a given namespace
129+
// The selector parameter follows the regular oc/kubectl format for the --selector option.
130+
func AssertAllPodsToBeReadyWithSelector(oc *CLI, namespace, selector string) {
131+
AssertAllPodsToBeReadyWithPollerParams(oc, namespace, 10*time.Second, 4*time.Minute, selector)
122132
}

0 commit comments

Comments
 (0)