From 517d6201f5e820bd24a63f44696729cb8cacfea7 Mon Sep 17 00:00:00 2001 From: Dan Mihai Date: Wed, 23 Apr 2025 21:28:49 +0000 Subject: [PATCH] ci: retry genpolicy execution genpolicy is sending more HTTPS requests than other components during CI so it's more likely to be affected by transient network errors similar to: ConnectError( "dns error", Custom { kind: Uncategorized, error: "failed to lookup address information: Try again", }, ) Note that genpolicy is not the only component hitting network errors during CI. Recent example from a different component: "Message: failed to create containerd task: failed to create shim task: failed to async pull blob stream HTTP status server error (502 Bad Gateway)" This CI change might help just with the genpolicy errors. Fixes: #11182 Signed-off-by: Dan Mihai --- tests/integration/kubernetes/tests_common.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/integration/kubernetes/tests_common.sh b/tests/integration/kubernetes/tests_common.sh index d87c9fad43..88637a014f 100644 --- a/tests/integration/kubernetes/tests_common.sh +++ b/tests/integration/kubernetes/tests_common.sh @@ -207,8 +207,15 @@ auto_generate_policy() { genpolicy_command+=" ${additional_flags}" - info "Executing: ${genpolicy_command}" - eval "${genpolicy_command}" + # Retry if genpolicy fails, because typical failures of this tool are caused by + # transient network errors. + for _ in {1..6}; do + info "Executing: ${genpolicy_command}" + eval "${genpolicy_command}" && return 0 + info "Sleeping after command failed..." + sleep 10s + done + return 1 } # Change genpolicy settings to allow "kubectl exec" to execute a command