diff --git a/apps/base/forgejo/pg-actions-queries.yaml b/apps/base/forgejo/pg-actions-queries.yaml index 6ad7492..0c937a0 100644 --- a/apps/base/forgejo/pg-actions-queries.yaml +++ b/apps/base/forgejo/pg-actions-queries.yaml @@ -38,13 +38,6 @@ kind: ConfigMap metadata: name: forgejo-actions-queries namespace: forgejo - labels: - # Tells the CNPG instance manager to re-read this ConfigMap on change. - # Without it a query fix (like the actions_runners dedupe below) does not - # reach the exporter until someone runs `kubectl cnpg reload` or the pod - # restarts — i.e. the fix appears to do nothing and /metrics keeps 500ing. - # This is a live reload of the queries, not a PostgreSQL restart. - cnpg.io/reload: "" data: queries: | # Queue depth: jobs handed to a runner that have not started, plus the age @@ -104,28 +97,11 @@ data: # How long ago each runner last polled Forgejo. This is the only signal that # says "the runner process is alive" independently of the pod being Ready — # a runner that cannot reach the forge stays Running but goes stale here. - # - # This query MUST return at most one row per `runner` label value. The - # exporter treats a duplicate label set as a programming error and answers - # the whole /metrics request with HTTP 500 — which also drops every - # pg_stat_*/cnpg_pg_* series, not just this one (incident t_290ff037). - # - # Two defences, both needed: - # * `r.deleted IS NULL` — Forgejo soft-deletes a runner (sets `deleted` to - # an epoch, keeps the row), so stale registrations survive in the table - # after a runner is removed. They are not real runners and stay hidden - # from the admin API, but a raw table read would see them. - # * `GROUP BY r.name` with `max(last_online)` — the label *is* the name, so - # two live rows that share a name (a re-registered runner, or one pod - # started from a copied runner.ini) would otherwise collide. Reporting - # the most recent poll per name is the semantic we want anyway. actions_runners: query: | SELECT r.name AS runner - , COALESCE(EXTRACT(EPOCH FROM pg_catalog.now())::bigint - NULLIF(max(r.last_online), 0), -1) AS last_online_seconds + , COALESCE(EXTRACT(EPOCH FROM pg_catalog.now())::bigint - NULLIF(r.last_online, 0), -1) AS last_online_seconds FROM action_runner r - WHERE r.deleted IS NULL - GROUP BY r.name metrics: - runner: usage: "LABEL"