Skip to content

Commit c92489f

Browse files
fix(ci): apply cr in nested cluster (#2319)
Description Add retry logic around kubectl apply calls in the nested E2E Configure Virtualization step. The workflow now writes the manifest received from stdin to a temporary file and retries the same kubectl apply command several times before failing. This covers transient Kubernetes API or DNS failures while applying ModuleSource, ModuleConfig, and ModulePullOverride resources. --------------- Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent 23794e0 commit c92489f

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/e2e-reusable-pipeline.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,35 @@ jobs:
971971
972972
- name: Configure Virtualization
973973
run: |
974+
kubectl_apply_with_retry() {
975+
local count=6
976+
local delay=10
977+
local manifest
978+
manifest="$(mktemp)"
979+
cat > "$manifest"
980+
981+
for i in $(seq 1 "$count"); do
982+
echo "[INFO] kubectl apply attempt ${i}/${count}"
983+
if kubectl apply -f "$manifest"; then
984+
rm -f "$manifest"
985+
return 0
986+
fi
987+
988+
if [ "$i" -lt "$count" ]; then
989+
echo "[WARN] kubectl apply failed, retrying in ${delay}s"
990+
sleep "$delay"
991+
fi
992+
done
993+
994+
echo "[ERROR] kubectl apply failed after ${count} attempts"
995+
rm -f "$manifest"
996+
return 1
997+
}
998+
974999
REGISTRY=$(base64 -d <<< "${{secrets.DEV_REGISTRY_DOCKER_CFG}}" | jq '.auths | to_entries | .[] | .key' -r)
9751000
9761001
echo "[INFO] Apply ModuleSource dev config"
977-
kubectl apply -f -<<EOF
1002+
kubectl_apply_with_retry <<EOF
9781003
apiVersion: deckhouse.io/v1alpha1
9791004
kind: ModuleSource
9801005
metadata:
@@ -990,7 +1015,7 @@ jobs:
9901015
kubectl wait --for=jsonpath='{.status.phase}'=Active ms deckhouse-dev --timeout=300s
9911016
9921017
echo "[INFO] Apply Virtualization module config"
993-
kubectl apply -f -<<EOF
1018+
kubectl_apply_with_retry <<EOF
9941019
apiVersion: deckhouse.io/v1alpha1
9951020
kind: ModuleConfig
9961021
metadata:

0 commit comments

Comments
 (0)