fix: skip healthy shared Argo reinstall

This commit is contained in:
Codex
2026-07-16 22:25:56 +02:00
parent 8cb9be8fb8
commit cac110af32
@@ -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"