From 55992ea48f32e13c503027f82784b9d3830e8137 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Fri, 16 Jan 2026 20:15:33 -0300 Subject: [PATCH] longhorn: make settings job idempotent --- .../longhorn/core/longhorn-settings-ensure-job.yaml | 2 +- .../longhorn/core/scripts/longhorn_settings_ensure.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/infrastructure/longhorn/core/longhorn-settings-ensure-job.yaml b/infrastructure/longhorn/core/longhorn-settings-ensure-job.yaml index 7c40721..f8e56cb 100644 --- a/infrastructure/longhorn/core/longhorn-settings-ensure-job.yaml +++ b/infrastructure/longhorn/core/longhorn-settings-ensure-job.yaml @@ -2,7 +2,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: longhorn-settings-ensure-2 + name: longhorn-settings-ensure-3 namespace: longhorn-system spec: backoffLimit: 0 diff --git a/infrastructure/longhorn/core/scripts/longhorn_settings_ensure.sh b/infrastructure/longhorn/core/scripts/longhorn_settings_ensure.sh index be188b0..f73a0cc 100644 --- a/infrastructure/longhorn/core/scripts/longhorn_settings_ensure.sh +++ b/infrastructure/longhorn/core/scripts/longhorn_settings_ensure.sh @@ -22,6 +22,14 @@ wait_for_api() { update_setting() { name="$1" value="$2" + + current="$(curl -fsS "${api_base}/${name}" || true)" + if echo "${current}" | grep -Fq "\"value\":\"${value}\""; then + echo "Setting ${name} already set." + return 0 + fi + + echo "Setting ${name} -> ${value}" curl -fsS -X PUT \ -H "Content-Type: application/json" \ -d "{\"value\":\"${value}\"}" \