From f89120662dba26f95f2bbd519b1bdee1196eecdf Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 29 Feb 2024 15:37:53 +0100 Subject: [PATCH 1/2] tests: k8s: Wait for all pods concurrently A single invocation of `kubectl wait` can handle all pods. Signed-off-by: Greg Kurz --- .../integration/kubernetes/k8s-sandbox-vcpus-allocation.bats | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats b/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats index d10ed95ce..fd2eab4d3 100644 --- a/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats +++ b/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats @@ -21,9 +21,11 @@ setup() { # Create the pods kubectl create -f "${pod_config_dir}/pod-sandbox-vcpus-allocation.yaml" + # Wait for completion + kubectl wait --for=jsonpath='{.status.conditions[0].reason}'=PodCompleted --timeout=$timeout pod --all + # Check the pods for i in {0..2}; do - kubectl wait --for=jsonpath='{.status.conditions[0].reason}'=PodCompleted --timeout=$timeout pod ${pods[$i]} [ `kubectl logs ${pods[$i]}` -eq ${expected_vcpus[$i]} ] done } From f3442cdef9891e695902c8370f4d2fed83b3a822 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Wed, 28 Feb 2024 18:08:40 +0100 Subject: [PATCH 2/2] tests: k8s: Adapt k8s-sandbox-vcpus-allocation.bats to kubernetes v1.29 Kubernetes v1.29 introduced a new `PodReadyToStartContainers` condition that gets inserted at index 0 in the conditions array. This means that the expected `PodCompleted` reason can now be either at index 0 with kubernetes v1.28 and older or at index 1 starting with kubernetes v1.29. This is fragile at best since the `kubectl wait` doesn't allow to combine multiple checks. Also, checking the reason is dubious as it doesn't really tell if the pods have actually completed or not. Check the pod phase to be `Succeeded` instead, this guarantees that : > All containers in the Pod have terminated in success, and will not > be restarted. Fixes #9178 Signed-off-by: Greg Kurz --- tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats b/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats index fd2eab4d3..0b0d7678e 100644 --- a/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats +++ b/tests/integration/kubernetes/k8s-sandbox-vcpus-allocation.bats @@ -22,7 +22,7 @@ setup() { kubectl create -f "${pod_config_dir}/pod-sandbox-vcpus-allocation.yaml" # Wait for completion - kubectl wait --for=jsonpath='{.status.conditions[0].reason}'=PodCompleted --timeout=$timeout pod --all + kubectl wait --for=jsonpath='{.status.phase}'=Succeeded --timeout=$timeout pod --all # Check the pods for i in {0..2}; do