From 60feb80691d1152da47ac0038cf043b5cf7e1d74 Mon Sep 17 00:00:00 2001 From: Simon Beck Date: Tue, 19 Mar 2024 08:36:25 +0100 Subject: [PATCH] Make e2e tests more reliable `kubectl run --attach` proved to be rather unreliable. It often was not able to attach to the newly created pod. There were various different error messages. By running the pod, waiting and then printing the logs, it improved the reliability by a lot. Where it previously failed ever so often, I was not able to have it fail once with the new function so far. Signed-off-by: Simon Beck --- e2e/lib/k8up.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/e2e/lib/k8up.bash b/e2e/lib/k8up.bash index 55ea298cf..b700fc04e 100755 --- a/e2e/lib/k8up.bash +++ b/e2e/lib/k8up.bash @@ -52,9 +52,12 @@ clear_pv_data() { mkdir -p ./debug/data/pvc-subject } +# We're not using `kubectl run --attach` here, to get the output of the pod. +# It's very unreliable unfortunately. So running the pod, waiting and getting the +# log output is a lot less prone for race conditions. restic() { - kubectl run "restic-$(timestamp)" \ - --attach \ + podname="restic-$(timestamp)" + kubectl run "$podname" \ --restart Never \ --namespace "${DETIK_CLIENT_NAMESPACE-"k8up-system"}" \ --image "${E2E_IMAGE}" \ @@ -68,7 +71,9 @@ restic() { --no-cache \ --repo "s3:http://minio.minio.svc.cluster.local:9000/backup" \ "${@}" \ - --json + --json > /dev/null + kubectl wait --for jsonpath='{.status.phase}'=Succeeded pod "$podname" -n "${DETIK_CLIENT_NAMESPACE-"k8up-system"}" --timeout=2m > /dev/null + kubectl -n "${DETIK_CLIENT_NAMESPACE-"k8up-system"}" logs "$podname" } replace_in_file() {