From ea6ef0d511a5552b4394c15a2d073a224a183c08 Mon Sep 17 00:00:00 2001 From: Shayan Namaghi Date: Thu, 16 Jul 2026 15:26:36 -0700 Subject: [PATCH] fix(setup): make Temporal namespace creation idempotent via describe Most of #2768 (error suppression, missing diagnostics) was already addressed on main by #2546 and #2675: namespace create output is captured, "already exists" is tolerated, genuine errors are propagated, and _verify_temporal_namespaces double-checks the result. This closes the remaining gap from the issue's expected behaviour: check namespace existence with 'temporal operator namespace describe' and skip creation when it already exists, instead of relying on the create call failing with "already exists". Any describe failure (not-found or transient) simply falls through to create, which already propagates real errors (TLS, auth, connectivity) with diagnostics. Fixes #2768 Signed-off-by: Shayan Namaghi --- helm-prereqs/setup.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helm-prereqs/setup.sh b/helm-prereqs/setup.sh index 234cdacd9b..da46ce1e05 100755 --- a/helm-prereqs/setup.sh +++ b/helm-prereqs/setup.sh @@ -687,6 +687,16 @@ _create_temporal_namespace() { local _namespace="$1" local _output + # Idempotency fast-path: skip creation when the namespace already exists. + # Any describe failure (not-found or transient) falls through to create, + # which propagates genuine errors with diagnostics below. + if kubectl exec -n temporal deploy/temporal-admintools -- \ + sh -c "temporal operator namespace describe -n \"\$1\" --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" \ + sh "${_namespace}" >/dev/null 2>&1; then + echo "Temporal namespace ${_namespace} already exists" + return + fi + if _output="$(kubectl exec -n temporal deploy/temporal-admintools -- \ sh -c "temporal operator namespace create -n \"\$1\" --retention 72h --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" \ sh "${_namespace}" 2>&1)"; then