From cac110af32a6dcff384d9775bb14357935a58c82 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 16 Jul 2026 22:25:56 +0200 Subject: [PATCH] fix: skip healthy shared Argo reinstall --- .../src/hwlab-node-control-plane-runtime.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/src/hwlab-node-control-plane-runtime.ts b/scripts/src/hwlab-node-control-plane-runtime.ts index bc4ad11a..58de2d82 100644 --- a/scripts/src/hwlab-node-control-plane-runtime.ts +++ b/scripts/src/hwlab-node-control-plane-runtime.ts @@ -1983,6 +1983,9 @@ export function argoApplyStartScript(node: ControlPlaneNodeSpec, target: Control const rewritesEncoded = Buffer.from(JSON.stringify(target.argo.install.imageRewrites), "utf8").toString("base64"); const preloadEncoded = Buffer.from(JSON.stringify(target.argo.install.preloadImages), "utf8").toString("base64"); const runtimeProxyEncoded = Buffer.from(JSON.stringify(runtimeHostProxyConfig(node, target.argo.install.runtimeProxy)), "utf8").toString("base64"); + const requiredCrds = target.argo.install.requiredCrds.map(shQuote).join(" "); + const expectedDeployments = target.argo.install.expectedDeployments.map(shQuote).join(" "); + const expectedStatefulSets = target.argo.install.expectedStatefulSets.map(shQuote).join(" "); return ` set -eu state_dir=${shQuote(stateDir)} @@ -2013,6 +2016,13 @@ path=pathlib.Path(sys.argv[1]) path.write_text(json.dumps({"state":sys.argv[2],"message":sys.argv[3],"updatedAt":time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())}, ensure_ascii=False) + "\\n") PY } +write_failed_status() { + rc=$? + if [ "$rc" -ne 0 ]; then + write_status failed "exit-$rc" + fi +} +trap write_failed_status EXIT { write_status running starting ${proxyExportBlock(node)} @@ -2020,6 +2030,17 @@ ${proxyExportBlock(node)} printf %s ${shQuote(rewritesEncoded)} | base64 -d >"$state_dir/image-rewrites.json" printf %s ${shQuote(preloadEncoded)} | base64 -d >"$state_dir/preload-images.json" printf %s ${shQuote(runtimeProxyEncoded)} | base64 -d >"$state_dir/runtime-proxy.json" + install_present=true + for name in ${requiredCrds}; do + kubectl get crd "$name" >/dev/null 2>&1 || install_present=false + done + for name in ${expectedDeployments}; do + kubectl -n "$namespace" get deployment "$name" >/dev/null 2>&1 || install_present=false + done + for name in ${expectedStatefulSets}; do + kubectl -n "$namespace" get statefulset "$name" >/dev/null 2>&1 || install_present=false + done + if [ "$install_present" != true ]; then kubectl create namespace "$namespace" --dry-run=client -o yaml | kubectl apply --server-side --field-manager="$field_manager" -f - || exit "$?" python3 - "$state_dir/preload-images.json" "$state_dir/image-rewrites.json" <<'PY' >"$state_dir/pull-images.sh" import json, pathlib, shlex, sys @@ -2120,6 +2141,9 @@ for kind in ["deployment", "statefulset"]: }}}} run(["kubectl", "-n", namespace, "patch", kind, name, "--type", "merge", "-p", json.dumps(patch)]) PY + else + printf '{"event":"argocd-install","status":"skipped","reason":"declared-install-present"}\\n' + fi deadline=$(( $(date +%s) + readiness_timeout )) while [ "$(date +%s)" -lt "$deadline" ]; do kubectl get crd applications.argoproj.io appprojects.argoproj.io >/dev/null 2>&1 && break @@ -2127,7 +2151,7 @@ PY done kubectl get crd applications.argoproj.io appprojects.argoproj.io >/dev/null || exit "$?" kubectl apply --server-side --force-conflicts --field-manager="$field_manager" -f "$desired_yaml" || exit "$?" - write_status succeeded argocd-install-applied + write_status succeeded argocd-desired-applied } >>"$log" 2>&1 || { rc=$? write_status failed "exit-$rc"