From 99688bbb020ba521f9e4dbb959b05d2463844bf1 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Fri, 17 Apr 2026 22:41:02 +0000 Subject: [PATCH] [uptime-kuma] Omit trailing slash when path annotation not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Context After commit f6812fe6 every external-monitor-sync run updated all ~107 monitors without any real change — because the new code always appended `/` to the host (default path), while historical monitors had been created with bare `https://host` URLs. Sync saw `https://host` != `https://host/` and re-wrote every monitor on each cycle: noisy logs, wasted Uptime Kuma writes. ## This change When the `uptime.viktorbarzin.me/external-monitor-path` annotation is absent, build the URL WITHOUT a trailing slash so it matches the shape of pre-existing monitors. When the annotation is set, append it as before (e.g. `https://forgejo.viktorbarzin.me/api/healthz`). Also flip the lenient/strict codes branch to trigger off the same "annotation set?" signal instead of comparing against DEFAULT_PATH. ## Verification Verified via two consecutive manual triggers of the CronJob against the live stack: Pass 1 (migration): 0 created, 107 updated, 0 deleted, 1 unchanged Pass 2 (stable): 0 created, 0 updated, 0 deleted, 108 unchanged `[External] forgejo` still probes `https://forgejo.viktorbarzin.me/api/healthz` with strict `200-299`. Co-Authored-By: Claude Opus 4.7 (1M context) --- stacks/uptime-kuma/modules/uptime-kuma/main.tf | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stacks/uptime-kuma/modules/uptime-kuma/main.tf b/stacks/uptime-kuma/modules/uptime-kuma/main.tf index 3eaccebf..e6009bc5 100644 --- a/stacks/uptime-kuma/modules/uptime-kuma/main.tf +++ b/stacks/uptime-kuma/modules/uptime-kuma/main.tf @@ -384,11 +384,14 @@ def load_from_api(): if monitor_name in seen: continue # dedupe by final monitor name, not hostname (fixes duplicate creation) seen.add(monitor_name) - path = anns.get(ANNOTATION_PATH) or DEFAULT_PATH - if not path.startswith("/"): + path = anns.get(ANNOTATION_PATH, "").strip() + if path and not path.startswith("/"): path = "/" + path - statuscodes = STATUSCODES_STRICT if path != DEFAULT_PATH else STATUSCODES_LENIENT - targets.append({"name": label, "url": f"https://{host}{path}", "statuscodes": statuscodes}) + # Omit trailing slash when no explicit path — matches pre-existing monitor URLs + # and avoids every sync re-updating unchanged monitors. + url = f"https://{host}{path}" if path else f"https://{host}" + statuscodes = STATUSCODES_STRICT if path else STATUSCODES_LENIENT + targets.append({"name": label, "url": url, "statuscodes": statuscodes}) return targets