Compare commits

...
Author SHA1 Message Date
atlas-botandClaude Opus 5.5 26e9f85afd test(monitoring): regenerate cnpg-backup suite for the one-rule shape (REN-152)
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
#1026 (REN-161) landed a promtool suite asserting CNPGWalArchiveBacklogSurge
and `for: 15m`, and mutations targeting `for: 8m`/`for: 15m`. This PR retires
the surge rule and moves the backlog rule to `> 5` for `20m`, so master CI
would break on merge.

- Generator: drop every Surge assertion; firing cases move to t=25m.
- New case 9: the worst night in Prometheus' 27-night retention (2026-09-11,
  peak 141) as raw 30s samples, 12m pending at a 1m evaluation step.
- mutations.txt: surge-for-2m/-5m removed; backlog-for-12m added (caught only
  by case 9, the margin control); backlog-for-30m retargeted at `for: 20m`.
- README and the woodpecker step comment updated to match.

Verified: scripts/ci/promtool-rules.sh with promtool 3.15.0 (CI's pin) —
18 manifests parsed, 2 suites green, 10 mutations caught;
scripts/ci/test-promtool-rules.sh passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 06:39:31 +00:00
atlas-botandClaude Opus 5 d39bcff92c fix(monitoring): one WAL-archive rule, >5 for 20m; drop the depth rule (REN-152)
Retune under Zeus's ruling on REN-152: the instrument is persistence, not
depth. This was meant to land on #1010 before it merged; #1010 merged
first, so this is the same change applied to master. Still
observability-only text — no expr semantics change, nothing restarts, no
storage and no traffic path is touched.

- CNPGWalArchiveBacklog `for`: 15m -> 20m.
- CNPGWalArchiveBacklogSurge (>64 for 8m) removed.

Why the depth rule goes. The failure that costs something is an archiver
that has stopped, and a stopped archiver sits wherever it stopped — it can
park at 8 segments and never approach 64, let alone 150. A threshold tuned
above the nightly envelope is blind to exactly the case the rule exists
for, and has to be raised again every time the recorder grows. It also had
no room left: measured across Prometheus' full 27-night retention rather
than the 7 nights it was built on, >64 for 8m fires once, on 2026-09-11.

Why 20m and not 15m. Same 27-night replay, 30s resolution, all 12 CNPG
instances. Only ha-pg-1 ever exceeds 5; every other instance peaks at 2.
Longest contiguous excursion above 5 is 13.0 minutes, on 2026-09-11 at a
peak of 141. Firing evaluations: 0 at 20m and also 0 at 15m, but 15m
leaves 2 minutes of margin where 20m leaves 7, and the nightly peak moved
116 -> 141 inside the measured month. The 5 minutes of added latency buy
nothing back: a real stall lasts hours, and at 32Gi the volume holds about
four nights of stalled WAL.

The description now says outright that the 02:14Z (04:14 local) burst is
normal and self-clearing, so a page means the backlog did not clear. The
drain-rate and headroom pointers (wal.maxParallel, spec.storage.size,
REN-135) move up from the deleted rule rather than being lost.

Verified with promtool 3.5.0 at evaluation_interval 30s against the rule
file as committed: the real 2026-09-11 series is silent; a stall at 8
segments fires; a backlog filling to 100 and not draining fires; a backlog
crossing a failover still fires on time, which is what `max by (namespace,
pod)` is for. Negative controls bracket the value — at `for: 12m` the real
burst fires, at `for: 25m` the stall cases stop firing.

Revert: `git revert` this commit. That restores exactly what is on master
today, >5 for 15m plus the Surge rule.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-27 06:36:44 +00:00
argus-bot (Paperclip service account) 2db8c217f6 Merge pull request 'feat(monitoring): alert when an ExternalSecret stops syncing (REN-103)' (#1002) from atlas/ren-103-eso-alert into master 2026-09-27 06:34:41 +00:00
argus-bot (Paperclip service account) 2d114a2dc6 Merge pull request 'monitoring: pin kube-prometheus-stack chart to 91.7.0 (REN-198)' (#1034) from atlas/ren-198-pin-kps-chart into master
ci/woodpecker/cron/e2e Pipeline failed
ci/woodpecker/cron/wiki-maintenance Pipeline was successful
ci/woodpecker/cron/issue-fix Pipeline was successful
ci/woodpecker/cron/alert-monitor Pipeline was successful
2026-09-26 20:35:45 +00:00
atlas-botandClaude Opus 5.5 36fba02a55 monitoring: pin kube-prometheus-stack chart to 91.7.0
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
The version range >=72.0.0 let Flux upgrade the chart unattended
(91.5.2 -> 91.7.0 at 19:43 UTC on 2026-09-26, no git commit). That
restart moved Prometheus onto k8s-1 while its Ceph RBD mounts were
broken, causing a ~48 min alerting outage (REN-198).

Pinned to the version already deployed, so reconcile is a no-op.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 20:34:08 +00:00
atlas-botandClaude Opus 5.5 3c318c0584 test(monitoring): move the ESO suite under tests/ so REN-161's CI runs it
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
promtool-rules.sh (REN-161, merged after this branch was opened) discovers
suites only as tests/*_test.yaml. At its old path the ESO suite would have
been skipped without a word. Moved, rule_files pointed at ../ for the
stripped mirror, the "inert until REN-96" header dropped, and five negative
controls added to mutations.txt: for 5m, sum-not-max, by-namespace,
no == 1, any condition. All five are caught.

promtool 3.15.0 (the CI pin): 18 manifests parsed, 2 suites green,
11 mutations caught. Rule file unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 16:17:06 +00:00
atlas-botandPaperclip 8ac19539a7 docs(monitoring): record the 8h flap baseline the 15m window was held for
Comment-only. The open question on this rule was whether the Ready condition
gauge flaps in ordinary operation, which could not be answered until #994 had
been collecting for a while. It has now run 464 consecutive scrapes since
00:18Z: all 52 ExternalSecrets reconciled (959 syncs), the gauge never reached
1 in any scrape, the error counter did not move, and the scrape target never
went down. Recorded in the rule file with the queries that produced it.

Also drops a reference to prometheusrule-ceph-test.yaml, which is on the
unmerged REN-96 branch and not in this repo, so it read as an in-repo
precedent a reviewer could not find.

Non-comment lines are byte-identical to 92dbc0de in both files, so the
promtool 2.53.2 check-rules and test-rules runs recorded on the PR still hold.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-09-26 16:16:21 +00:00
atlas-botandClaude Opus 5 8014272d2b docs(monitoring): record the live series counts the rule was checked against
Comment-only. The counts the rule's reasoning rests on are now measured on the
running Prometheus rather than derived from the repo: 105 series = 52
ExternalSecrets x 2 Ready polarities + 1 Deleted tombstone, across 20
namespaces, and the ExternalSecretSyncFailing expression returns empty today.
The last point is the one a reviewer wants: the rule arrives silent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-26 16:16:21 +00:00
atlas-bot d6c0742783 docs(monitoring): show the ESO alert group actually re-notifies, and is not inhibited
Comment-only, again: `diff` of all non-comment lines against bbaf0c6a is empty.

Answers the grouping objection raised in review. Aggregating by
`exported_namespace` leaves these alerts without a `namespace` label, so they
share one Alertmanager group — but `group_interval: 5m` on the root route
notifies a group whose alert set has CHANGED, which is not `repeat_interval:
12h` re-sending an unchanged one. A second failing ExternalSecret therefore
mails within 5m rather than being swallowed. Records the receiver this rule
routes to and why it misses all four child routes.

Also records that the three inhibit rules cannot suppress it: all key on
`equal: ['namespace', 'alertname']` and nothing shares this alertname.
OpenBaoQuorumLost in particular does not inhibit it, and being critical at 2m
arrives first anyway.

Refs REN-103
2026-09-26 16:16:21 +00:00
atlas-bot 0f1b50ece8 docs(monitoring): record why the gauge beats the counter, with the live numbers
Comment-only. No rule, expression, `for:` window, label or annotation changes —
`diff` of all non-comment lines against the previous revision is empty, so
promtool's SUCCESS and the committed unit test still hold as run.

Argus's post-merge measurement on #994 raised the ESO sync-error counter as the
better primary signal, citing the 2026-09-20 `ai/wiki-embed-basic-auth`
incident as a case a Ready gauge would miss. Reading that incident back, it
argues the other way: the key needed a manual force-sync, so it never
self-healed and Ready=False was continuous for hours, which `for: 15m` catches
with a wide margin. It was a stuck condition, not a flap.

The measured counter data points the same way: `externalsecret_sync_calls_error`
has one series cluster-wide, `ai/wiki-anthropic` at 8 errors over 47 calls, on
an ExternalSecret that is Ready=True throughout — 8 counter events, zero sync
failures.

Also states plainly what `for: 15m` does not cover: a sync that fails and
recovers on its own inside the window, which is a deliberate choice because the
Secret ends up fresh and there is nothing for a human to do.

Refs REN-103
2026-09-26 16:16:21 +00:00
atlas-botandClaude Opus 5 33a8480f53 feat(monitoring): alert when an ExternalSecret stops syncing (REN-103)
Merge B of REN-103. #994 made the series exist; this is the rule built on
them. Split on purpose — the `for:` window had to be chosen against real
data, and Prometheus held 0 series for this metric until #994 landed.

Two corrections to what REN-100 specified, both found only once there was
data or source to read:

  * `exported_namespace`, not `namespace`. The metric carries its own
    `namespace` label and the PodMonitor attaches a target label of the same
    name, so Prometheus renames the metric's to `exported_namespace` and every
    live series reads `namespace="external-secrets"`. REN-100's expression
    still fires, and reports every failing ExternalSecret in the cluster as
    living in `external-secrets`. Found by Argus against the live data.

  * `max`, not `sum`. Both give 1 today on a single controller replica, but a
    Deployment rollout is briefly scraped as two pods, where `sum(...) == 1`
    evaluates to 2 and silently stops matching.

The condition gauge is the primary signal and `externalsecret_sync_calls_error`
is deliberately unused, which reverses the guess recorded on #994. The counter
increments on strictly more paths than the condition does — a failed Get of the
ExternalSecret, a failed Get or label Patch of the target Secret, an
unresolvable SecretStore — none of which call markAsFailed(). It is the noisier
signal, not the quieter one. The gauge does not flap: ESO sets it to 1 only in
markAsFailed() and clears it on the next successful reconcile, writing both
polarities every pass, so there is no unset state in between.

`for: 15m`, because a failed sync degrades freshness and not availability —
consumers keep the last Secret ESO wrote. Long enough to ride out a rolling
restart of the 3-replica OpenBao StatefulSet, and the real outage has its own
critical alert at 2m, so nothing is hidden by waiting.

Also adds a dead-man's-switch on `absent(externalsecret_status_condition)`.
Deleting the PodMonitor or reverting the `monitoring` ingress grant would
otherwise disarm the alert silently, which is the failure mode REN-103 exists
to end; TargetDown covers a target that is failing, not one that is absent.

Verified with promtool 2.53.2: `check rules` passes, and the committed
`-test.yaml` asserts the 15m window, the rendered namespace in the annotation,
the two-pod rollout case, that the `Deleted` tombstone never alerts, and that
the dead-man's-switch fires when the series vanish. Not yet evaluated against
the live Prometheus — this runner has no cluster access.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-26 16:16:21 +00:00
argus-bot (Paperclip service account) 3d6169ec05 Merge pull request 'feat(monitoring): warn before Ceph nearfull — per-OSD and replicapool headroom (REN-163)' (#1025) from atlas/ren-163-ceph-nearfull-headroom into master
ci/woodpecker/cron/issue-fix Pipeline failed
ci/woodpecker/cron/alert-monitor Pipeline was successful
2026-09-26 15:09:31 +00:00
argus-bot (Paperclip service account) 0e2dea3ee2 Merge pull request 'fix(velero): read-only snapshot backup PVC for ceph-filesystem-bulk (REN-177)' (#1030) from atlas/ren-177-velero-cephfs-readonly-backuppvc into master 2026-09-26 15:01:11 +00:00
argus-bot (Paperclip service account) 7acdb36d52 Merge pull request 'uptime-monitor: attach owner's alert contacts to the pilot monitors (REN-7)' (#1031) from atlas/ren-7-alert-contacts into master
ci/woodpecker/cron/e2e Pipeline failed
ci/woodpecker/cron/security-scan Pipeline was successful
ci/woodpecker/cron/issue-fix Pipeline was successful
ci/woodpecker/cron/alert-monitor Pipeline was successful
2026-09-26 11:47:00 +00:00
atlas-botandClaude Opus 5.5 56e9814437 uptime-monitor: attach owner's alert contacts to the pilot monitors (REN-7)
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
Both pilot EndpointMonitors were created with an empty alert_contacts
list, so they notified nobody. Set uptimeRobotConfig.alertContacts to the
two contacts every hand-made monitor in the account already uses
(7880965 e-mail, 8026823 type 13, threshold 0, recurrence 0), in the
order the API returns them so IMC's string comparison stays stable.

Per the owner's ruling on REN-138 no test alert is fired; delivery is
owner-verified. Revert this commit to return to empty contacts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:45:53 +00:00
argus-bot (Paperclip service account) ff085a0586 Merge pull request 'ci: cite YAML by anchor instead of line number, and guard it (REN-183)' (#1027) from atlas/ren-183-yaml-anchors into master
ci/woodpecker/cron/issue-fix Pipeline was successful
ci/woodpecker/cron/alert-monitor Pipeline was successful
2026-09-26 10:38:26 +00:00
atlas-botandClaude Opus 5.5 25acbd4f1e fix(velero): read-only snapshot backup PVC for ceph-filesystem-bulk
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
backupPVC in node-agent-config is keyed by source storage class.
ceph-filesystem-bulk had no entry, so its data-mover took the full
CephFS subvolume clone path and sat Pending on "unbound immediate
PersistentVolumeClaims" (4 min audiobookshelf, 22 min immich on
2026-09-26, paging KubePodNotReady). Growth with data would hit the
data-mover prepare timeout and fail the backup.

- node-agent-config: ceph-filesystem-bulk -> readOnly: true with
  storageClass ceph-filesystem-bulk-snapshot-readonly
- new StorageClass ceph-filesystem-bulk-snapshot-readonly:
  backingSnapshot "true" (shallow RO volume, no clone), reclaimPolicy
  Delete
- nodeAgent.podLabels revision label so node-agent restarts and loads
  the config (node-agent only, not the server)

Refs REN-177.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 10:35:39 +00:00
security-bot 5bdb29e1e0 chore(image-automation): bump ghcr.io/paperclipai/paperclip:nightly@sha256:1da39019a9b48c2b9318a5f037978765d226c8ef6838545fa691f3f8200bccac
ci/woodpecker/cron/alert-monitor Pipeline was successful
Updates managed by image-automation-controller.
2026-09-26 10:25:33 +00:00
k.renner 783a680184 Merge pull request 'feat(paperclip): LAN-only API door for external agents' (#1029) from feat/paperclip-api-door into master
ci/woodpecker/cron/issue-fix Pipeline was successful
ci/woodpecker/cron/alert-monitor Pipeline was successful
Reviewed-on: k.renner/homelab#1029
2026-09-26 09:24:20 +00:00
atlas-botandClaude Opus 5.5 21a7583523 ci: cite YAML by anchor instead of line number, and guard it (REN-183)
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
Comments that pointed at other YAML as `file.yaml:N` went stale on any
edit above the cited line; three drift fixes had been merged by hand
(REN-181). The cited block now carries `# anchor: <name>` and the
comment cites `path.yaml#<name>`.

- Sweep: all 32 line-number citations in YAML comments converted.
  Several were already stale at head and now point at the right block
  (see PR). Vendored files (Flux gotk-components, IMC CRD) get no
  anchor; those two citations name the object/schema path instead.
- Guard: scripts/ci/yaml-citations.sh in ci-manifests-test.yml; fails
  on a line-number citation or a path#name whose file/anchor is gone.
  Self-test in ci-scripts-test.yml.
- CONTRIBUTING.md: the convention in three lines.

Comment-only under kubernetes/: every file parses to identical objects
before and after, so Flux applies nothing and no ConfigMap data changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 08:44:54 +00:00
8d2323b347 feat(monitoring): warn before Ceph nearfull, per-OSD and replicapool (REN-163)
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
Ceph's mon_osd_nearfull_ratio is 0.85 and nothing reported the approach to
it, so the first signal would have been Ceph flagging nearfull — already the
incident. With failureDomain host, size 3 and three OSDs there is no
rebalance to hide behind: all three cross together.

Two warning rules, both observability only:

- CephOSDNearfullApproaching: fullest OSD sustained >= 75% for 30m. 0.75 is
  0.85 minus the largest measured bulk burst (+10.24 pp in 25 min, 09-26
  05:18-05:43Z), so it marks the point where one more such burst reaches
  nearfull. 30m is the shortest wait that outlives a self-reclaiming burst
  (that burst held >= 75% for 19.0 min) and short enough to fire before 0.85
  at the fastest observed sustained climb (+11.44 pp/h).

- CephReplicapoolHeadroomLow: replicapool max_avail < 160 GiB for 30m.
  160 = 89 GiB held above the 0.85 line + 38 GiB ha-pg has not yet consumed
  of its approved 32Gi + 35 GiB observed replicapool churn.

Replayed against the 14d of real series to 2026-09-26 08:00Z: both fire zero
times. Worst 30m-sustained OSD floor 71.632%; lowest 30m-sustained
replicapool ceiling 208.97 GiB. Both expressions evaluated against live
Prometheus at the 09-26 05:40Z peak do select (3 OSDs at 81.87%,
replicapool at 117.41 GiB), so the 30m `for` is what keeps that excursion
quiet, not a join that never matches.

Thresholds are unmerged pending the owner's yes on REN-163.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-26 08:11:45 +00:00
38 changed files with 1187 additions and 573 deletions
+24 -3
View File
@@ -36,6 +36,7 @@ when:
- "kubernetes/**"
- ".woodpecker/**"
- "scripts/ci/promtool-rules.sh"
- "scripts/ci/yaml-citations.sh"
# THE THIRD DISCOVERY CHECK WENT TO A SCRIPT. kustomize-build and shellcheck
# both hand-roll the same shape — `find`, a floor guard against empty discovery,
@@ -50,10 +51,10 @@ when:
# ci-scripts-test.yml. A FOURTH inline copy should go the same way; do not add
# one here.
#
# Every step carries `depends_on: []` so all five run in PARALLEL and every
# Every step carries `depends_on: []` so all six run in PARALLEL and every
# failure shows in one run. Woodpecker's default is sequential, which would stop
# at the first failure and make a contributor fix-and-repush to discover the
# next — and these five are independent, cheap, offline checks with no ordering
# next — and these six are independent, cheap, offline checks with no ordering
# between them. Keep it on every step: `depends_on` is per-step, so dropping it
# from one silently re-serialises that step behind the others.
steps:
@@ -285,7 +286,8 @@ steps:
# and 04:22 local for a backlog that clears itself. Nothing here would have
# caught it, and the arithmetic that did catch it was hand-written from scratch
# twice, in two runs, and thrown away both times because there was nowhere in
# the repo to commit it. It is now mutations.txt:surge-for-2m.
# the repo to commit it. REN-152 retired that rule; its `for` margin is now
# guarded by mutations.txt:backlog-for-12m.
#
# Offline, like the rest of this pipeline: no cluster, no registry, no secrets,
# no network. promtool reads files and exits.
@@ -320,3 +322,22 @@ steps:
image: prom/prometheus:v3.15.0
commands:
- sh scripts/ci/promtool-rules.sh
# Comments cite other YAML blocks by anchor name, never by line number
# (REN-183; the exact syntax is in CONTRIBUTING.md, not repeated here because
# an example written in this comment would itself be checked). Line numbers drift on any edit
# above them and nothing noticed: three drift fixes were merged by hand
# before this step existed. This fails on a new line-number citation and on
# a citation whose file or anchor marker does not exist.
# Existence only — it never judges whether the anchored block still says
# what the citing comment claims, so ordinary edits cannot turn it red.
#
# It scans every YAML file in the checkout, but this pipeline only runs on
# the paths in `when:` above, so an edit confined to ansible/ or esphome/ is
# checked on the next PR that does touch kubernetes/ or .woodpecker/.
# Self-test: scripts/ci/test-yaml-citations.sh, in ci-scripts-test.yml.
- name: yaml-citations
depends_on: [] # see note above `steps:`
image: gitea.renner.uno/gitea_admin/ci-k8s:2026-09-08
commands:
- sh scripts/ci/yaml-citations.sh
+8 -2
View File
@@ -23,14 +23,14 @@
# only runs when someone remembers to touch the right directory is not a guard.
#
# Only in homelab (scripts/ci/ lives here); the file is not deployed to the
# mirrored repos, so it does not run on their PRs. Both tests are offline (no
# mirrored repos, so it does not run on their PRs. All tests here are offline (no
# token, no network, no cluster) — the ci-claude image just provides sh + jq, and
# it is already pulled by pr-review.yml on the same event, so the runner has it
# cached.
when:
- event: pull_request
# `depends_on: []` on both so they run in parallel and one failure does not hide
# `depends_on: []` on every step so they run in parallel and one failure does not hide
# the other. Same reasoning as the note above `steps:` in ci-manifests-test.yml.
steps:
- name: model-selection-tests
@@ -44,3 +44,9 @@ steps:
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.280
commands:
- sh scripts/ci/test-promtool-rules.sh
- name: yaml-citations-guard-tests
depends_on: []
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.280
commands:
- sh scripts/ci/test-yaml-citations.sh
+7
View File
@@ -0,0 +1,7 @@
# Contributing
## Citing other YAML from a comment
- Mark the block you cite with a comment line `# anchor: <name>` (kebab-case, unique in that file). If the block is inside a `|` block scalar, put the marker just above the key, never inside the scalar.
- Cite it as `path.yaml#<name>`, with the path relative to the citing file's directory or to the repo root. Never cite `path.yaml:<line>`, because line numbers go stale on any edit above them.
- `scripts/ci/yaml-citations.sh` enforces this in `ci-manifests-test.yml`: it fails on line-number citations and on citations whose file or anchor does not exist.
+5 -3
View File
@@ -40,12 +40,13 @@ metadata:
# fixed in place because the sentence lives inside the `config.yaml: |` block
# scalar below: any edit to it changes ConfigMap DATA, and
# `configmap.reloader.stakater.com/reload: gatus-config`
# (gatus/deployment.yaml:13) would then roll the gatus Deployment — a
# (deployment.yaml#reloader) would then roll the gatus Deployment — a
# production restart for a comment. This header is outside `data:`, so it is
# inert; the served config is byte-identical.
#
# * infrastructure/network-policies/paperless-ns.yaml:34-36 ALREADY admits
# the whole monitoring namespace on every port, and monitoring is where
# * ../../infrastructure/network-policies/paperless-ns.yaml#monitoring-admit
# ALREADY admits the whole monitoring namespace on every port, and
# monitoring is where
# blackbox-exporter runs. Cilium unions the allow rules of every CNP
# selecting an endpoint, so no extra policy is required.
# * The in-cluster paperless probe therefore exists, added with no change
@@ -60,6 +61,7 @@ metadata:
# The Web Service 11 entry below stays a reachability-only check on purpose.
# The app-health half of the pair is the blackbox probe named above.
data:
# anchor: gatus-endpoints
config.yaml: |
storage:
type: sqlite
+1
View File
@@ -6,6 +6,7 @@ metadata:
labels:
app: gatus
annotations:
# anchor: reloader
# Gatus reads its config once at startup and never re-reads the file, so
# without this a ConfigMap change reconciles cleanly and then does nothing:
# git and the running checks drift apart silently, with no failed resource
@@ -55,6 +55,10 @@ resources:
# infrastructure/network-policies/external-secrets-ns.yaml in the same change,
# or it scrapes nothing. See the file.
- external-secrets-podmonitor.yaml
# The alert built on what that PodMonitor collects. Split from it on purpose:
# the `for:` window had to be chosen against real series, and Prometheus held
# none for this metric until the scrape landed.
- prometheusrule-external-secrets.yaml
# Flux's own control plane. The controllers were never scraped, so nothing
# about Flux's behaviour was queryable. Scrape only: per-object readiness is
# not on this endpoint at the pinned controller versions and needs
@@ -93,10 +93,11 @@ spec:
# are the first targets here that leave the monitoring namespace.
#
# Both sit entirely behind an Authentik outpost — navidrome.renner.uno
# on ak-outpost-navidrome-gate (navidrome/ingress.yaml:21),
# lidarr.renner.uno on ak-outpost-lidarr-gate
# (navidrome/lidarr.yaml:218) — so an EXTERNAL probe of either name
# measures the gate, not the app, and stays green while the app behind
# on ak-outpost-navidrome-gate
# (../navidrome/ingress.yaml#navidrome-gate), lidarr.renner.uno on
# ak-outpost-lidarr-gate (../navidrome/lidarr.yaml#lidarr-gate) — so an
# EXTERNAL probe of either name measures the gate, not the app, and
# stays green while the app behind
# a live gate is dead. That external signal is still wanted, and REN-2
# adds it from UptimeRobot; these are the other half of the pair.
#
@@ -124,7 +125,7 @@ spec:
# infrastructure/network-policies/monitoring-ns.yaml
# (default-deny-ingress) and monitoring-alloy-syslog.yaml
# (allow-syslog-world-ingress). blackbox-exporter runs in that same
# namespace (apps/monitoring/helmrelease-blackbox-exporter.yaml:5).
# namespace (../monitoring/helmrelease-blackbox-exporter.yaml#namespace).
# Re-verified at 2b71dda1 across all 635 yaml files in the repo — 73
# Cilium objects, 38 carrying an egress or egressDeny block, none of
# them in the monitoring namespace, and the single
@@ -142,9 +143,10 @@ spec:
# gatus checks, so status.renner.uno is unaffected and no workload is
# restarted. What breaks is the signal, and it breaks misleadingly.
# All three targets start failing BlackboxProbeFailing
# (prometheusrule-blackbox.yaml:34 — severity warning, for: 10m); none
# of the three is in that rule's exclusion list. BlackboxProbesAbsent
# does NOT fire, because the other 17 targets keep producing
# (prometheusrule-blackbox.yaml#blackbox-probe-failing — severity
# warning, for: 10m); none of the three is in that rule's exclusion
# list. BlackboxProbesAbsent does NOT fire, because the other 17
# targets keep producing
# probe_success — so it reads as three apps going down, not as a
# policy change. WHO NOTICES: warning routes to the default `email`
# receiver, admin@renner.uno (helmrelease-prometheus.yaml alertmanager
@@ -156,16 +158,17 @@ spec:
# `flux reconcile kustomization monitoring-rules --with-source`.
#
# /ping on both: unauthenticated, and already the pods' own kubelet
# probe path (navidrome/deployment.yaml:80-93,
# navidrome/lidarr.yaml:114-127). For lidarr that it is ungated is
# proven independently of the gate — lidarr.yaml:29 curls /ping in a
# probe path (../navidrome/deployment.yaml#kubelet-probes,
# ../navidrome/lidarr.yaml#kubelet-probes). For lidarr that it is
# ungated is proven independently of the gate — its reconcile script
# (../navidrome/lidarr.yaml#reconcile-script) curls /ping in a
# loop BEFORE it has read the API key out of config.xml.
#
# STATUS CODE, unproven for all three of the new targets: module
# http_2xx follows redirects and passes only on a FINAL 2xx, while
# every piece of repo evidence behind these paths establishes only
# `< 400` — a kubelet httpGet accepts 200-399, and lidarr.yaml:29's
# `curl -f` without -L exits 0 on a 302. That evidence proves the
# `< 400` — a kubelet httpGet accepts 200-399, and that reconcile
# script's `curl -f` without -L exits 0 on a 302. That evidence proves the
# paths are UNGATED, not that they answer 200. Check
# probe_http_status_code on the first scrapes; a target that settles
# on a 3xx gets REVERTED, not widened to accept 3xx.
@@ -207,10 +210,12 @@ spec:
# BLAST RADIUS paragraph above.
- http://navidrome.navidrome.svc.cluster.local:80/ping
- http://lidarr.navidrome.svc.cluster.local:80/ping
# anchor: paperless-app-health
# APP-HEALTH probe for paperless. Same rule as the block above
# (monitoring-vantage-point-rule); the blind spot it closes is the one
# gatus already documents at apps/gatus/configmap.yaml:205-214 —
# through the paperless-gate outpost EVERY path, /api/ included,
# gatus already documents in its Web Service 11 comment
# (../gatus/configmap.yaml#gatus-endpoints) — through the
# paperless-gate outpost EVERY path, /api/ included,
# answers 302 to an unauthenticated caller, so no external probe of
# paperless.renner.uno can tell a live app from a live gate. That
# external signal is still wanted, and REN-2 adds it from UptimeRobot;
@@ -218,10 +223,12 @@ spec:
#
# That gatus comment says the in-cluster probe "needs a
# CiliumNetworkPolicy first". That sentence is simply WRONG, not
# merely inapplicable: paperless-ns.yaml:34-36 already admits the
# whole monitoring namespace, which is where blackbox-exporter runs,
# merely inapplicable:
# ../../infrastructure/network-policies/paperless-ns.yaml#monitoring-admit
# already admits the whole monitoring namespace, which is where
# blackbox-exporter runs,
# and Cilium unions the allow rules of every CNP selecting an
# endpoint (the mechanism apps/paperless/network-policy.yaml:22-26
# endpoint (the mechanism ../paperless/network-policy.yaml#cnp-union
# relies on). The EGRESS paragraph in the block above applies here
# identically. Nothing in the paperless namespace is edited by this
# change.
@@ -229,19 +236,22 @@ spec:
# The stale sentence is deliberately left in place in
# apps/gatus/configmap.yaml: it sits INSIDE the `config.yaml: |`
# block scalar, so editing it changes ConfigMap data and
# `configmap.reloader.stakater.com/reload` (gatus/deployment.yaml:13)
# rolls the gatus Deployment. The correction is written at the top of
# `configmap.reloader.stakater.com/reload`
# (../gatus/deployment.yaml#reloader) rolls the gatus Deployment. The
# correction is written at the top of
# that file instead, outside `data:`, where it costs no restart.
#
# /accounts/login/ because paperless-ngx has no unauthenticated health
# endpoint at all. It is the app's own established "the webserver
# answers" signal — the same path its startup, liveness and readiness
# probes use (paperless.yaml:252-272) — and it renders a Django view
# probes use (../paperless/paperless.yaml#http-probes) — and it
# renders a Django view
# rather than a static file. It does NOT cover the consumer/celery
# workers: see process-liveness-vs-protocol-liveness.
#
# The cluster-local Host header is accepted only because
# PAPERLESS_ALLOWED_HOSTS is "*" (paperless.yaml:27). Narrow that and
# PAPERLESS_ALLOWED_HOSTS is "*"
# (../paperless/paperless.yaml#allowed-hosts). Narrow that and
# Django answers 400 here and this probe goes permanently red.
#
# This is the target most likely to fail the STATUS CODE check in the
@@ -335,10 +345,12 @@ spec:
# WHY A SEPARATE jobName, and why these must NEVER be folded into the
# blackbox-http Probe above: after PR 2b these targets fail permanently and BY
# DESIGN. BlackboxProbeFailing and BlackboxProbesAbsent
# (prometheusrule-blackbox.yaml:35,50) are both scoped to job="blackbox-http",
# so a distinct job is outside both and stays silent — and the hand-maintained
# instance!~ exclusion regex at :35, whose fragility that file warns about, does
# not have to grow a fifth entry. Adding these to blackbox-http instead would
# (prometheusrule-blackbox.yaml#blackbox-probe-failing and
# prometheusrule-blackbox.yaml#blackbox-probes-absent) are both scoped to
# job="blackbox-http", so a distinct job is outside both and stays silent — and
# the hand-maintained instance!~ exclusion regex in the first of them, whose
# fragility that file warns about, does not have to grow a fifth entry. Adding
# these to blackbox-http instead would
# page the on-call forever.
#
# The inverted alert that gives these targets teeth — CNPNegativeControlReachable,
@@ -377,12 +389,14 @@ spec:
# exporter's 9187). Neither that rule nor paperless-allow-blackbox
# exists yet at this commit — that is the point, and why this target
# must read 1 now. Service is CNPG-generated from Cluster `pprl-pg`
# (paperless/cluster.yaml:4) and is the name paperless itself dials
# (paperless.yaml:46).
# (../paperless/cluster.yaml#pprl-pg) and is the name paperless itself
# dials (../paperless/paperless.yaml#db-host).
- pprl-pg-rw.paperless.svc.cluster.local:5432
# Three witnesses that the whole-namespace `monitoring` admit is gone
# for workloads no new rule selects. Ports from the Services themselves:
# redis.yaml:76, tika.yaml:57, gotenberg.yaml:63.
# ../paperless/redis.yaml#service-port,
# ../paperless/tika.yaml#service-port,
# ../paperless/gotenberg.yaml#service-port.
- redis.paperless.svc.cluster.local:6379
- tika.paperless.svc.cluster.local:9998
- gotenberg.paperless.svc.cluster.local:3000
@@ -23,7 +23,8 @@
#
# NO POLICY CHANGE IS NEEDED TO MAKE THESE WORK TODAY. Ingress: the paperless
# baseline still admits the whole `monitoring` namespace on every port
# (infrastructure/network-policies/paperless-ns.yaml:34-36) — that admission is
# (../../infrastructure/network-policies/paperless-ns.yaml#monitoring-admit) —
# that admission is
# exactly what REN-28 removes. Egress: the `monitoring` namespace is in no
# egress enforcement at all; its only two Cilium policies, monitoring-ns.yaml
# and monitoring-alloy-syslog.yaml, are ingress-only. Same dependency the three
@@ -88,7 +89,8 @@ spec:
# The test as written in §7 says "a paperless POD port other than
# 8000"; there is no such port. The paperless pod's only other listener
# is the bridge-tls-proxy socat, bound to 127.0.0.1:11143
# (apps/paperless/paperless.yaml:289), so every other port on that pod
# (../paperless/paperless.yaml#bridge-tls-proxy), so every other port
# on that pod
# is closed today and answers RST — there is no "reachable before" to
# record and the port half of paperless-allow-blackbox (:8000) cannot
# be tested at all. gotenberg is the half that CAN be: it is one of the
@@ -31,6 +31,7 @@ spec:
# target means. A target whose loss deserves a critical page gets its
# own rule — and lands in the list above. That is what keeps the
# exclusion list from being arbitrary.
# anchor: blackbox-probe-failing
- alert: BlackboxProbeFailing
expr: probe_success{job="blackbox-http", instance!~"https://fsn1\\.your-objectstorage\\.com|https://netbird\\.renner\\.uno|http://proxy-[12]\\.renner\\.uno:9000/health|https://ci\\.renner\\.uno|https://openbao\\.renner\\.uno/v1/sys/health.*"} == 0
for: 10m
@@ -46,6 +47,7 @@ spec:
# The check that the checks are running. Every rule above reads
# probe_success; if the series stop being produced at all, none of them
# can fire and the silence looks exactly like health.
# anchor: blackbox-probes-absent
- alert: BlackboxProbesAbsent
expr: absent(probe_success{job="blackbox-http"})
for: 15m
@@ -137,3 +137,116 @@ spec:
annotations:
summary: "{{ $labels.instance }} /var below 30% free — Ceph mon will warn"
description: "/var on {{ $labels.instance }} is under 30% free, which is Ceph's mon_data_avail_warn threshold, so the mon on this node will report MON_DISK_LOW. Find the actual consumer with `talosctl -n <node> usage /var/lib --depth 1` and then `/var/lib/containerd --depth 1` — note that overlayfs snapshots belong to running containers and are not reclaimable by image GC."
- alert: CephOSDNearfullApproaching
# Warns BEFORE Ceph's own nearfull check, which is the incident and
# not a warning. mon_osd_nearfull_ratio is 0.85 and is not
# overridden here.
#
# There is no rebalance to hide behind: failureDomain is host with
# size 3 on exactly three OSDs, so every OSD holds a copy of every
# replicated object and all three cross 0.85 within seconds of each
# other. Measured 2026-09-26: 81.86 / 81.87 / 81.83%.
#
# 0.75 is 0.85 minus the largest bulk-tier burst on record. Measured
# at 30s resolution over the 14d to 2026-09-26: the fullest OSD went
# 71.63% -> 81.87% between 05:18 and 05:43Z (+10.24 pp, ~275 GiB raw)
# and reclaimed within the hour. At a SUSTAINED 75%, one more burst of
# that size reaches nearfull, which is the point at which the level
# itself is the finding.
#
# `for: 30m` is the shortest wait that outlives a self-reclaiming
# burst. That same burst held >= 75% for 19.0 min, so 30m clears it by
# 11 min; a permanent step holds it indefinitely. Do NOT shorten this
# to 15m — the 09-26 burst then pages, with the cluster reclaiming on
# its own while someone reads the mail.
#
# Nor should it be lengthened to 1h. The fastest observed SUSTAINED
# climb was +11.44 pp in one hour (2026-09-25 08:02-09:02Z, a real
# ingest that never reclaimed). From 75% that reaches 0.85 in ~53 min,
# so a 1h pending window would fire after nearfull, not before it.
# 30m fires at ~80.7% in that worst case — about 22 min of lead — and
# at 2.24 pp/h (the worst 6h-sustained rate) it fires at ~76.1%, about
# 4h of lead. The 30m/1h choice is the whole trade: a burst reclaims
# in ~20 min and a step does not, so ~30m is the earliest honest
# verdict. REN-162 is measuring the burst envelope; if a burst is ever
# seen holding >= 75% for more than ~25 min, this `for` moves out, not
# the threshold.
#
# Replay over the 14d to 2026-09-26 08:00Z: the worst 30m-sustained
# floor on any OSD was 71.632% (09-26 04:31Z), so this rule fires ZERO
# times on the observed normal shape, including the 09-26 excursion to
# 81.87% and the 09-25 step from 59% to 71%. Margin 3.37 pp.
#
# `max by (ceph_daemon)` is not cosmetic. rook-ceph-exporter pods are
# replaced often — 32 distinct series for three OSDs in 14 days — and
# the raw expression carries `pod` and `instance`, so every restart
# would change the alert identity and reset a pending window.
expr: |
max by (ceph_daemon) (
ceph_osd_stat_bytes_used / ceph_osd_stat_bytes
) >= 0.75
for: 30m
labels:
severity: warning
annotations:
summary: "Ceph {{ $labels.ceph_daemon }} sustained above 75% — one bulk burst from nearfull"
description: "{{ $labels.ceph_daemon }} has been at or above 75% utilisation for 30 minutes ({{ $value | humanizePercentage }} now). That is 0.85 nearfull minus the largest bulk-tier burst measured here (+10.24 pp in 25 minutes), so a single repeat of that burst trips mon_osd_nearfull_ratio — and with failureDomain host, size 3 and three OSDs, it trips on all three at once with no rebalance available. This is sustained, not a spike: a burst clears in about 20 minutes and never holds this for 30. Find what grew with `kubectl -n rook-ceph exec deploy/rook-ceph-tools -- ceph df` and `ceph osd df tree`; the bulk tier (cephfs-bulk, pool 15) is the usual mover."
- alert: CephReplicapoolHeadroomLow
# The `replicapool` counterpart to the OSD rule above, in the units a
# reader can act on: GiB that still fit.
#
# These two are NOT independent signals and must not be read as
# corroboration. `ceph_pool_max_avail` for a size-3 pool on three
# equal OSDs is exactly (full_ratio - fullest_OSD_utilisation) x
# osd_size; verified against live data, the identity holds at 0.95 to
# five decimals. So this rule is the OSD series rescaled — a second
# TIER, deliberately set to trip after the OSD rule, not a second
# opinion. Ceph's own nearfull line of 0.85 sits at 89.4 GiB here.
#
# 160 GiB is what must still fit, measured:
# 89 GiB max_avail at the 0.85 nearfull line, i.e. the part of
# max_avail that is not ours to spend
# 38 GiB ha-pg's unconsumed allocation after the approved 20Gi ->
# 32Gi expansion: 2 instances x (31.33 GiB provisioned -
# 12.4 GiB used) as of 2026-09-26
# 35 GiB replicapool churn allowance — the worst observed single
# day (+14.3 GiB, 09-23) plus eleven days at the 14d mean
# of 1.9 GiB/day
# = 162 GiB, rounded DOWN to 160 so the rounding costs quiet, not
# headroom.
#
# Selecting on the pool NAME through ceph_pool_metadata, not on a
# hardcoded pool_id: ids are assignable and replicapool is only id 1
# by history. `on(pool_id)` is the whole matcher for the same reason
# given on CephPoolLostRedundancy above — ceph_pool_metadata carries
# labels ceph_pool_max_avail does not, so default matching never
# joins.
#
# `max by (pool_id)` twice over: it collapses the churning mgr `pod`
# and `instance` labels (8 series in 14 days), and during an mgr
# failover it takes the live value rather than a stale low one.
#
# `for: 30m` also covers a real exporter artefact: ceph_pool_max_avail
# reads exactly 0 for a single 30s sample after an mgr restart, twice
# in the 14d window (e.g. 09-23 12:27Z), on every mgr series at once.
# A `for` shorter than a few minutes would page on that alone. Note
# the glitch is one-directional, so it cannot cancel a genuine breach
# — 0 is still below the floor.
#
# Replay over the 14d to 2026-09-26 08:00Z: the lowest 30m-sustained
# ceiling was 208.97 GiB (09-26 04:31Z), so ZERO fires on the observed
# normal shape. The 09-26 burst took max_avail to 117.4 GiB for about
# 10 minutes and did not come close to holding it.
expr: |
max by (pool_id) (
ceph_pool_max_avail
and on(pool_id) ceph_pool_metadata{name="replicapool"}
) < 160 * 1024^3
for: 30m
labels:
severity: warning
annotations:
summary: "replicapool usable headroom below 160 GiB"
description: "replicapool has had under 160 GiB usable for 30 minutes ({{ $value | humanize1024 }}B now). 160 GiB is the 89 GiB that max_avail still holds above Ceph's 0.85 nearfull line, plus the 38 GiB ha-pg has not yet consumed of its 32Gi expansion, plus 35 GiB of observed replicapool churn — below this, what is already committed no longer fits before nearfull. This is the same series as CephOSDNearfullApproaching rescaled (max_avail = (0.95 - fullest OSD) x OSD size), so it is a second tier and not independent confirmation. Check `kubectl -n rook-ceph exec deploy/rook-ceph-tools -- ceph df`; growth here is usually the bulk tier on the shared OSDs, not replicapool itself."
@@ -28,101 +28,74 @@ spec:
# discussed below it does not depend on Cluster status being
# populated.
#
# Threshold: >5 segments sustained for 15m. Brief non-zero values are
# normal under write bursts — a segment is 16 MiB, so 5 is roughly
# 80 MiB of un-archived WAL, well below anything that threatens the
# volume but far above idle noise.
# Threshold: >5 segments sustained for 20m. A segment is 16 MiB, so 5
# is roughly 80 MiB of un-archived WAL — well below anything that
# threatens the volume, but far above idle noise.
#
# `for` was 30m and is now 15m (REN-129). To be clear about what that
# does and does not buy: this rule does NOT fire on the nightly write
# burst documented under the Surge rule below, at 30m or at 15m, and
# that is correct — across seven consecutive measured nights the
# longest contiguous excursion above 5 was 10 minutes and every one
# of them drained itself. What 15m is for is the case that actually
# costs something: an archiver that has stopped. Outside those
# nightly windows the metric is a hard 0 on all 12 CNPG instances in
# this cluster, so there was never a noise floor that needed 30m to
# wait out — the extra 15m only delayed that page.
# WHAT THIS RULE KEYS ON: persistence, not depth. The failure that
# costs something is an archiver that has *stopped*, and a stopped
# archiver can sit at 60 segments indefinitely without ever reaching
# some larger number. A depth threshold tuned above the nightly
# envelope below would miss exactly that case, and would need raising
# again every time the recorder grows. So there is one rule here, and
# the tuning knob is `for` (REN-152).
#
# `max by (namespace, pod)` is not cosmetic. The raw series carries
# `role`, which flips on failover; a changed label is a new series,
# and a new series restarts the `for` timer. Aggregating `role` away
# means a backlog that persists across a failover still pages 15m
# after the backlog started rather than 15m after the failover.
expr: max by (namespace, pod) (cnpg_collector_pg_wal_archive_status{value="ready"}) > 5
for: 15m
labels:
severity: warning
annotations:
summary: "CNPG WAL archiving is falling behind on {{ $labels.namespace }}/{{ $labels.pod }}"
description: "{{ $value }} WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n {{ $labels.namespace }} logs {{ $labels.pod }} -c plugin-barman-cloud`."
- alert: CNPGWalArchiveBacklogSurge
# Companion to CNPGWalArchiveBacklog above, for the opposite failure
# shape: not a stuck archiver, but a working archiver that cannot
# drain as fast as Postgres is producing.
#
# CNPGWalArchiveBacklog cannot see that shape at any `for` value that
# is also safe against a flapping archiver, because the event is over
# before the window closes.
#
# What is normal here, measured on ha-pg-1 at 1-minute steps over the
# seven nights 2026-09-19 to 2026-09-26 (REN-129). Every night is the
# same burst, and nothing in that week exceeds 5 at any other hour:
# THE NIGHTLY BURST, which this rule must stay silent through.
# ha-pg-1 queues WAL every night on the same clock:
#
# flat 0 until 02:12Z; fill from 02:13Z; peak 02:14-02:15Z;
# drained by 02:22Z. Nightly peaks 56, 91, 100, 101, 106, 113, 119.
# drained by 02:26Z at the worst. 02:12Z is 04:12 local, which is
# when Home Assistant's recorder purge runs.
#
# This is a write burst, not IO contention. Drain was 13.0-14.9
# segments/min on all seven nights — including the night whose Kopia
# repository-maintenance batch did not start until after the burst had
# already drained, and the night when two such jobs were saturating
# the RBD devices. That batch drifts across 02:03-02:24Z while the
# peak stays pinned to 02:15Z, and a drifting cause cannot produce an
# effect fixed to the clock. What varies is the fill (18.7-39.7
# segments/min), so the height of the backlog is set by how much WAL
# is produced against an archiver with a flat ~14 segments/min
# ceiling. 02:12Z is 04:12 local, which is when Home Assistant's
# recorder purge runs.
# It is a write burst, not IO contention. Drain is a flat
# 13-15 segments/min every night — including nights when Kopia's
# repository-maintenance batch was saturating the RBD devices, and
# nights when it did not start until after the burst had already
# drained. That batch drifts across 02:03-02:24Z while the peak stays
# pinned to 02:15Z, and a drifting cause cannot produce an effect
# fixed to the clock. What varies is the fill (19-40 segments/min),
# so the height of the backlog is set by how much WAL is produced
# against an archiver with a flat ~14 segments/min ceiling.
#
# So the nightly burst is a benign, self-clearing fact of this
# cluster and this rule has to stay silent through it. Threshold:
# >64 segments (1 GiB of un-archived WAL) for 8m.
# WHY 20m. Measured against Prometheus' full 27-night retention
# (2026-08-30..2026-09-26), at the real 30s scrape resolution, across
# all 12 CNPG instances. Only ha-pg-1 ever exceeds 5 at all; every
# other instance peaks at 2. Longest contiguous excursion above 5 on
# any night: 13.0 minutes, on 2026-09-11, at a peak of 141 segments.
# Firing evaluations over those 27 nights: 0 at 20m, and also 0 at
# 15m — but 15m leaves only 2 minutes of margin against the worst
# night, and the nightly peak climbed from 116 to 141 inside the
# measured month as the recorder grew. 20m leaves 7 minutes and does
# not have to be re-derived every time the database gets bigger.
#
# - 64, not something nearer the >5 above, because this rule is
# deliberately not a faster copy of that one. 1 GiB is where the
# backlog becomes a material fraction of a CNPG PVC's free space
# (ha-pg's volume is 20Gi, holding steady at 6.4-7.7 GiB free),
# and a rule that trips on every write spike is how the
# load-bearing rule above gets ignored.
# - 8m because the measured envelope spends at most 5 consecutive
# minutes above 64 on any of the seven nights, so 8m clears the
# worst observed night by 3 minutes. An earlier revision of this
# rule used 2m; that fires at ~02:16Z on 6 of the 7 nights, which
# is two owner emails a night at 04:16 and 04:22 local for a
# condition that repairs itself.
# The 5 minutes 20m costs in detection latency buy nothing back: a
# real stall lasts hours, and at 32Gi (REN-141) the volume holds
# roughly four nights of stalled WAL before free space is in danger.
#
# What 8m still catches: 1 GiB queued that is not moving. From 119,
# the highest peak in the week, a healthy archiver is back under 64
# inside 5 minutes. Sitting above it for 8 means the archiver has
# lost most of its throughput, and that is worth a 04:00 look.
# `for` was 30m before REN-129. Outside the nightly windows the
# metric is a hard 0 on all 12 instances, so there was never a noise
# floor that needed 30m to wait out — the extra 10m only delayed the
# page.
#
# When it does fire, the fix is drain rate or headroom, never a
# higher threshold here. ObjectStore `wal.maxParallel`
# WHEN IT FIRES, the fix is drain rate or headroom, never a higher
# threshold here. ObjectStore `wal.maxParallel`
# (kubernetes/apps/home-assistant/ha-pg-objectstore.yaml) is unset,
# which the barman-cloud plugin reads as one WAL segment at a time;
# that is where the ~14 segments/min ceiling comes from. Headroom is
# `spec.storage.size` in ha-pg-cluster.yaml. Both are REN-135.
#
# `max by (namespace, pod)` for the same reason as the rule above:
# `role` flips on failover and would restart the `for` timer.
expr: max by (namespace, pod) (cnpg_collector_pg_wal_archive_status{value="ready"}) > 64
for: 8m
# `max by (namespace, pod)` is not cosmetic. The raw series carries
# `role`, which flips on failover; a changed label is a new series,
# and a new series restarts the `for` timer. Aggregating `role` away
# means a backlog that persists across a failover still pages 20m
# after the backlog started rather than 20m after the failover.
expr: max by (namespace, pod) (cnpg_collector_pg_wal_archive_status{value="ready"}) > 5
for: 20m
labels:
severity: warning
annotations:
summary: "CNPG WAL archiving cannot keep up on {{ $labels.namespace }}/{{ $labels.pod }}"
description: "{{ $value }} WAL segments (>1 GiB) have been queued for archiving for 8 minutes, which is longer than a healthy archiver needs to clear that much — from a backlog of 119 it takes under 5. Point-in-time recovery is degraded for everything after the last archived segment, and pg_wal grows against the PVC's free space until it clears. Start with the archiver: `kubectl -n {{ $labels.namespace }} logs {{ $labels.pod }} -c plugin-barman-cloud`, and check whether its ObjectStore sets `wal.maxParallel` — unset means one segment at a time, a ceiling of about 14 segments/min (REN-129)."
summary: "CNPG WAL archiving is falling behind on {{ $labels.namespace }}/{{ $labels.pod }}"
description: "{{ $value }} WAL segments have been waiting to archive for over 20 minutes. NOTE ON TIMING: a nightly write burst on ha-pg-1 at 02:14Z (04:14 local) is normal and drains itself within about 13 minutes, and this rule is tuned to stay silent through it — so if this fired, the backlog did NOT clear and the archiver is stuck. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n {{ $labels.namespace }} logs {{ $labels.pod }} -c plugin-barman-cloud`."
- alert: CNPGBackupFailed
# cnpg_collector_last_failed_backup_timestamp is a unix timestamp, 0
@@ -0,0 +1,227 @@
# Alert when an ExternalSecret stops syncing.
#
# This is the second half of REN-103. The first half (#994) added the PodMonitor
# and the `monitoring` ingress grant that make the series exist at all; before
# that, `externalsecret_status_condition` held 0 series and a key that silently
# stopped refreshing was invisible to Prometheus, to Alertmanager and to anyone
# looking at a dashboard. The alert is split out because its `for:` window had to
# be chosen against real data rather than guessed.
#
# `exported_namespace`, NOT `namespace`. The metric carries its own `namespace`
# label (the ExternalSecret's), and the PodMonitor attaches a target label of the
# same name (the controller pod's, always `external-secrets`). Prometheus resolves
# that collision by renaming the metric's label to `exported_namespace`, so on
# every one of the ~105 live series `namespace="external-secrets"`. Grouping by
# `namespace` would therefore still fire correctly and still be useless: every
# failing ExternalSecret in the cluster would be reported as living in
# `external-secrets`. ESO's own shipped Grafana dashboard does group by
# `namespace` — that is right for the chart's ServiceMonitor, which scrapes ESO
# through its own Service and injects no conflicting target label, and wrong here.
# This is a general trap for the PodMonitor-instead-of-ServiceMonitor trade this
# repo keeps making: any metric carrying its own `namespace`, `pod` or `container`
# label gets it shadowed.
#
# `honorLabels: true` on the PodMonitor endpoint would keep the clean label name
# instead, and is deliberately not used: it drops the target labels, so nothing
# records which controller replica reported, and it would make this the only
# monitor in the directory doing so.
#
# A consequence worth knowing rather than fixing: aggregating by
# `exported_namespace` leaves these alerts with no `namespace` label at all, and
# Alertmanager's route groups on ['alertname', 'cluster', 'namespace']. So every
# failing ExternalSecret arrives in ONE email listing all of them, each named by
# its own annotation, instead of one email per namespace. For a fleet this size
# that is the better shape.
#
# The obvious worry about that shape — that a SECOND ExternalSecret failing while
# the first alert is already firing gets swallowed by the open group — does not
# hold, and the setting that decides it is `group_interval: 5m` on the root route
# in apps/monitoring/helmrelease-prometheus.yaml. `group_interval` governs
# notification of a group whose alert SET has changed, which is a different thing
# from `repeat_interval: 12h`, which governs re-sending an unchanged group. A
# second failure therefore produces a fresh email naming both within 5 minutes.
# This rule routes to the root `email` receiver: it is `severity: warning` and
# carries no `source = "flux"`, so it matches none of the four child routes.
#
# The inhibit rules are also checked and do not touch these alerts. All three key
# on `equal: ['namespace', 'alertname']` (or `['namespace']`), and no critical or
# warning alert in the cluster shares this `alertname`. In particular
# OpenBaoQuorumLost does NOT inhibit this rule — different alertname — so an
# OpenBao outage can surface both. That is the intended order rather than a
# problem: OpenBaoQuorumLost is critical at 2m and arrives first, well before
# this rule's 15m.
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: external-secrets
namespace: monitoring
labels:
# kube-prometheus-stack's ruleSelector matches on this label; without it the
# rule is created but never loaded into Prometheus.
release: kube-prometheus-stack
spec:
groups:
- name: external-secrets.rules
rules:
# Measured against the live Prometheus before this rule was proposed for
# merge, through the apiserver services/proxy read path:
#
# count(externalsecret_status_condition) = 105
# count(count by (exported_namespace,name) (...)) = 53
# count(count by (exported_namespace,name) (...{condition="Ready"})) = 52
# count(count by (exported_namespace) (...)) = 20
# count(...{condition="Ready",status="False"}) = 52
# the ExternalSecretSyncFailing expression below = EMPTY
#
# So 105 = 52 ExternalSecrets x 2 Ready polarities + 1 Deleted tombstone,
# across 20 namespaces, and THIS RULE ARRIVES SILENT: it matches nothing
# in the cluster as it stands, which is what makes it safe to load. The
# 52 on the line below is a count, not an estimate.
#
# `== 1` IS LOAD-BEARING, not defensive. ESO writes BOTH polarities of the
# Ready condition on every reconcile — the true one at 1 and the opposite
# at 0 (esmetrics.UpdateExternalSecretCondition) — so
# `{condition="Ready",status="False"}` is present with value 0 for every
# healthy ExternalSecret. A bare selector would match all 52 of them.
#
# `max`, not the `sum` the vendor dashboard uses. Both give 1 today,
# because ESO runs a single controller replica. During a Deployment
# rollout Prometheus can briefly scrape the old and the new pod at once,
# and `sum(...) == 1` would then evaluate to 2 and silently STOP matching
# — the alert would resolve itself in the middle of a failure. `max` is 0
# or 1 whatever the replica count.
#
# The gauge, not `externalsecret_sync_calls_error`. The counter was the
# other candidate, on the theory that a counter cannot flap the way a
# condition gauge might. Reading the controller says the opposite on both
# halves: the counter increments on strictly MORE paths than the condition
# does — a failed Get of the ExternalSecret itself, a failed Get or label
# Patch of the target Secret, an unresolvable SecretStore — and none of
# those call markAsFailed(), so none of them set Ready=False. A cache blip
# or an apiserver hiccup moves the counter and nothing else. It is the
# noisier signal, not the quieter one. And the gauge does
# not flap, because it is set to 1 only by markAsFailed() and cleared by
# the next successful reconcile. There is no unset state in between.
#
# The live numbers say the same thing, measured after #994 landed:
# `externalsecret_sync_calls_error` has exactly one series in the whole
# cluster, `ai/wiki-anthropic`, at 8 errors over 47 calls — and that
# ExternalSecret is Ready=True and has never been otherwise in the
# observation window. So on today's data the counter carries 8 events that
# correspond to no sync failure at all, and the gauge carries none.
#
# That observation window is now long enough to mean something, and it is
# the answer to the only open question this rule was held back for — how
# much the gauge flaps in ordinary operation. Measured 2026-09-26T08:02Z,
# over the 464 consecutive scrapes since #994 started collecting at
# 00:18Z:
#
# min_over_time(up{job="monitoring/external-secrets"}[8h]) = 1
# sum(increase(externalsecret_sync_calls_total[8h])) = 959
# count(increase(externalsecret_sync_calls_total[8h]) > 0) = 52
# count(max_over_time(
# externalsecret_status_condition{
# condition="Ready",status="False"}[8h]) == 1) = EMPTY
# sum(increase(externalsecret_sync_calls_error[8h])) = 0
#
# Every one of the 52 ExternalSecrets reconciled at least once in that
# window — 959 syncs, so the 1h and 10m refreshInterval cycles both turned
# over repeatedly — and across all of them the Ready gauge never reached 1
# in a single scrape. Zero flap amplitude, against real reconcile traffic
# rather than against silence. The counter was flat over the same window
# too, which is why 8 stays 8 above. `for: 15m` is therefore not damping
# anything measurable; it is derived from the failure modes below, and the
# data says no shorter window would have been noisy either.
#
# The 2026-09-20 `ai/wiki-embed-basic-auth` incident is evidence FOR this
# rule, not against it, though it reads the other way at first. That key
# sat in ESO retry backoff through ~10 failures and NEEDED A MANUAL
# force-sync (the incident is written up in
# clusters/homelab/uptime-monitor.yaml, as the in-repo proof for REN-100).
# Because it never self-healed, Ready=False was continuous from the first
# failure until a human intervened — hours, not minutes. `for: 15m` catches
# that with a wide margin. It was a stuck condition, not a flap; the flap
# reading would only hold if the retries had eventually succeeded on their
# own, and they did not.
- alert: ExternalSecretSyncFailing
expr: >-
max by (exported_namespace, name) (
externalsecret_status_condition{condition="Ready",status="False"}
) == 1
# 15m, and the reason it can be this relaxed is that a failed sync is
# not an outage: consumers keep using the last Secret ESO wrote, so what
# degrades is freshness, not availability. Nothing here needs catching
# inside a minute.
#
# It needs to be at least this long because the provider-error path
# returns the error to controller-runtime, which retries with
# exponential backoff rather than waiting out `refreshInterval`. A
# momentary OpenBao blip is therefore cleared within seconds and never
# reaches 15m, while a rolling restart of the 3-replica OpenBao
# StatefulSet is ridden out entirely — and that outage has its own
# alert (OpenBaoQuorumLost, critical at 2m), so nothing is hidden by
# waiting. 15m of continuous Ready=False means repeated failure.
for: 15m
labels:
severity: warning
annotations:
summary: "ExternalSecret {{ $labels.exported_namespace }}/{{ $labels.name }} is not syncing"
description: >-
ESO has been unable to sync this ExternalSecret for 15 minutes. The
Secret it manages still holds its last successfully synced value, so
consumers keep working — what breaks is that a rotation at the
provider no longer propagates, which surfaces much later as a
credential that stopped being accepted. Get the reason with
`kubectl -n {{ $labels.exported_namespace }} get externalsecret
{{ $labels.name }} -o jsonpath='{.status.conditions}'`; the common
causes are a key that was renamed or removed in OpenBao, a
ClusterSecretStore that cannot authenticate, and a target Secret
owned by something else.
# Dead-man's-switch, mirroring ExternalDNSMetricsMissing and
# OpenBaoMetricsMissing. The alert above can only fire on series that
# exist, so deleting the PodMonitor, reverting the `monitoring` ingress
# grant in infrastructure/network-policies/external-secrets-ns.yaml, or
# bumping the ESO chart onto a metrics port that no longer matches would
# all disarm it silently — which is the exact failure mode REN-103 exists
# to end. TargetDown does not cover this: it reports a target that exists
# and is failing, not the absence of a target.
- alert: ExternalSecretMetricsMissing
expr: absent(externalsecret_status_condition)
for: 15m
labels:
severity: warning
annotations:
summary: "No ExternalSecret metrics are reaching Prometheus"
description: >-
`externalsecret_status_condition` has no series. Either the ESO
controller is gone or its scrape stopped being collected, and
ExternalSecretSyncFailing is blind for as long as this is true.
Check the PodMonitor `monitoring/external-secrets` still selects the
controller pods, and that external-secrets-ns.yaml still admits
`monitoring` on TCP/8080.
# NOT covered here, deliberately, so nobody assumes it is:
#
# * `condition="Deleted"`. In chart 2.11.0 the only writer of that
# condition is the NotFound branch of Reconcile, which fabricates
# `Deleted=False` purely to make UpdateExternalSecretCondition drop
# the object's Ready series. It is a tombstone for an ExternalSecret
# that no longer exists, not a health state, and `Deleted=True` is
# never emitted at all — a rule on it would be dead code. The one such
# series in the cluster today (`ai/wiki-index-basic-auth`) is leftover
# process state for an ExternalSecret that moved namespace; it clears
# when the controller next restarts.
# * An ExternalSecret that exists in the cluster but was never
# reconciled emits no series at all, so nothing above can see it. That
# needs object-existence data — kube-state-metrics custom resource
# state — rather than ESO's own metrics, and is not in this change.
# * A sync that fails and then succeeds on its own inside 15m. This is a
# choice, not an oversight: the retry left the Secret holding a freshly
# synced value, so nothing degraded and there is nothing for a human to
# do. Alerting on it would mean paging for a self-healed event. The case
# that would justify revisiting is the same failure recurring for days
# without any single occurrence lasting 15m, which would show up as a
# climbing `externalsecret_sync_calls_error` on an ExternalSecret that
# is Ready=True. Nothing in the cluster shows that shape today, and the
# rule for it needs a measured recurrence rate rather than a guess.
@@ -18,8 +18,8 @@ value. Against Iris's seven measured nights it fires on six of them — two owne
emails a night, 04:16 and 04:22 local, for a WAL backlog that clears itself in
under ten minutes. It was caught by a human writing the arithmetic out by hand,
twice, in two separate runs, and throwing the work away both times because
there was nowhere in the repo to put it. That rule is now
`mutations.txt:surge-for-2m`.
there was nowhere in the repo to put it. [REN-152](/REN/issues/REN-152) then
retired the depth rule in favour of one persistence rule (`> 5` for `20m`).
## Layout
@@ -27,6 +27,7 @@ there was nowhere in the repo to put it. That rule is now
| --- | --- |
| `cnpg-backup_test.yaml` | The suite. **Generated** — see below. |
| `generate-cnpg-backup-test.py` | Regenerates it from the REN-129 measurement table. |
| `external-secrets_test.yaml` | Hand-written suite for `prometheusrule-external-secrets.yaml` (REN-103). |
| `mutations.txt` | Negative controls. Each must make the suite fail. |
## Adding a suite
@@ -90,10 +91,10 @@ the assertions reach the rules — both failure modes above were green. So
breaks one value the rules depend on and requires the suites to **fail**. A
mutation nothing notices is reported as a hole in the suite.
This is also the answer to "why is that case in there". `surge-for-5m` is
silent on all seven real nights and fires only on the adversarial envelope
case, so deleting the envelope case makes `for: 8m` reducible to `5m` with the
suite still green. The control is what makes the case load-bearing.
This is also the answer to "why is that case in there". `backlog-for-12m` is
silent on all seven reconstructed nights and fires only on the raw 2026-09-11
worst-night case, so deleting that case makes `for: 20m` reducible to `12m`
with the suite still green. The control is what makes the case load-bearing.
Mutations are `name|manifest-path|sed-program`, applied to the stripped copy in
the mirror (two spaces shallower than the manifest on disk — anchor on
@@ -105,10 +106,9 @@ otherwise renaming a rule quietly turns its control into a no-op.
Margin is **pending** time, which is one minute less than the run length. An
alert goes pending at the first evaluation where the expression is true and
fires when `now - activeAt >= for`, so N consecutive one-minute samples above a
threshold accumulate N-1 minutes. A trace with 5 samples above 64 does not fire
`for: 5m`; it fires `for: 4m`. The `>5 pend` and `>64 pend` columns in
`--report` are the numbers to compare a `for` against — not the sample counts
next to them.
threshold accumulate N-1 minutes. A trace with 5 samples above 5 does not fire
`for: 5m`; it fires `for: 4m`. The `>5 pend` column in `--report` is the number
to compare a `for` against — not the sample count next to it.
## Running it locally
@@ -3,9 +3,10 @@
#
# Unit tests for kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml.
# Every assertion below is either one of Iris's seven measured nights
# (REN-129) rebuilt from its published (peak, fill, drain) numbers, an
# (REN-129) rebuilt from its published (peak, fill, drain) numbers, the
# worst night in Prometheus' retention as raw samples (REN-152), an
# adversarial combination of the extremes of those numbers, or a failure
# this cluster has not had but the rules exist to catch.
# this cluster has not had but the rule exists to catch.
#
# `rule_files` entries are resolved RELATIVE TO THIS FILE'S DIRECTORY, not
# to the working directory promtool was invoked from — promtool joins
@@ -24,13 +25,12 @@ evaluation_interval: 1m
tests:
# ---------------------------------------------------------------------
# 1-7. THE SEVEN MEASURED NIGHTS. Both rules must stay silent through
# every one of them. This is the half of the suite that has already
# caught something: the surge rule shipped for review at `for: 2m` and
# fires here on 6 of these 7 nights (mutations.txt:surge-for-2m).
# 1-7. THE SEVEN MEASURED NIGHTS. The rule must stay silent through
# every one of them. The retired depth rule (`> 64`) shipped for review
# at `for: 2m` and fired on 6 of these 7 nights; REN-152 removed it.
# ---------------------------------------------------------------------
# 2026-09-20: the nightly Home Assistant recorder purge at 04:12 local.
# peak 106 at 02:15Z, fill 35.3/min, drain 13.2/min -> 10 samples above 5 (9m pending vs for: 15m), 5 above 64 (4m pending vs for: 8m).
# peak 106 at 02:15Z, fill 35.3/min, drain 13.2/min -> 10 samples above 5 (9m pending vs for: 20m).
- name: nightly burst 2026-09-20 — recorder purge, benign, self-clearing
interval: 1m
input_series:
@@ -46,37 +46,17 @@ tests:
- eval_time: 7m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:15Z, backlog 106
- eval_time: 7m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:18Z, backlog 66
- eval_time: 10m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:18Z, backlog 66
- eval_time: 10m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:22Z, backlog 14
- eval_time: 14m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:22Z, backlog 14
- eval_time: 14m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:24Z, backlog 0
- eval_time: 16m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:24Z, backlog 0
- eval_time: 16m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 2026-09-21: the nightly Home Assistant recorder purge at 04:12 local.
# peak 100 at 02:15Z, fill 33.3/min, drain 14.3/min -> 9 samples above 5 (8m pending vs for: 15m), 4 above 64 (3m pending vs for: 8m).
# peak 100 at 02:15Z, fill 33.3/min, drain 14.3/min -> 9 samples above 5 (8m pending vs for: 20m).
- name: nightly burst 2026-09-21 — recorder purge, benign, self-clearing
interval: 1m
input_series:
@@ -92,37 +72,17 @@ tests:
- eval_time: 7m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:15Z, backlog 100
- eval_time: 7m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:17Z, backlog 71
- eval_time: 9m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:17Z, backlog 71
- eval_time: 9m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:21Z, backlog 14
- eval_time: 13m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:21Z, backlog 14
- eval_time: 13m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:23Z, backlog 0
- eval_time: 15m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:23Z, backlog 0
- eval_time: 15m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 2026-09-22: the nightly Home Assistant recorder purge at 04:12 local.
# peak 101 at 02:15Z, fill 33.7/min, drain 14.4/min -> 9 samples above 5 (8m pending vs for: 15m), 4 above 64 (3m pending vs for: 8m).
# peak 101 at 02:15Z, fill 33.7/min, drain 14.4/min -> 9 samples above 5 (8m pending vs for: 20m).
- name: nightly burst 2026-09-22 — recorder purge, benign, self-clearing
interval: 1m
input_series:
@@ -138,37 +98,17 @@ tests:
- eval_time: 7m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:15Z, backlog 101
- eval_time: 7m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:17Z, backlog 72
- eval_time: 9m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:17Z, backlog 72
- eval_time: 9m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:21Z, backlog 15
- eval_time: 13m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:21Z, backlog 15
- eval_time: 13m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:23Z, backlog 0
- eval_time: 15m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:23Z, backlog 0
- eval_time: 15m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 2026-09-23: the nightly Home Assistant recorder purge at 04:12 local.
# peak 119 at 02:15Z, fill 39.7/min, drain 14.9/min -> 10 samples above 5 (9m pending vs for: 15m), 5 above 64 (4m pending vs for: 8m).
# peak 119 at 02:15Z, fill 39.7/min, drain 14.9/min -> 10 samples above 5 (9m pending vs for: 20m).
- name: nightly burst 2026-09-23 — recorder purge, benign, self-clearing
interval: 1m
input_series:
@@ -184,37 +124,17 @@ tests:
- eval_time: 7m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:15Z, backlog 119
- eval_time: 7m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:18Z, backlog 74
- eval_time: 10m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:18Z, backlog 74
- eval_time: 10m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:22Z, backlog 15
- eval_time: 14m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:22Z, backlog 15
- eval_time: 14m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:24Z, backlog 0
- eval_time: 16m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:24Z, backlog 0
- eval_time: 16m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 2026-09-24: the nightly Home Assistant recorder purge at 04:12 local.
# peak 56 at 02:14Z, fill 18.7/min, drain 14.0/min -> 6 samples above 5 (5m pending vs for: 15m), 0 above 64 (0m pending vs for: 8m).
# peak 56 at 02:14Z, fill 18.7/min, drain 14.0/min -> 6 samples above 5 (5m pending vs for: 20m).
- name: nightly burst 2026-09-24 — recorder purge, benign, self-clearing
interval: 1m
input_series:
@@ -230,29 +150,17 @@ tests:
- eval_time: 6m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:14Z, backlog 56
- eval_time: 6m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:17Z, backlog 14
- eval_time: 9m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:17Z, backlog 14
- eval_time: 9m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:19Z, backlog 0
- eval_time: 11m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:19Z, backlog 0
- eval_time: 11m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 2026-09-25: the nightly Home Assistant recorder purge at 04:12 local.
# peak 91 at 02:15Z, fill 22.8/min, drain 13.0/min -> 10 samples above 5 (9m pending vs for: 15m), 4 above 64 (3m pending vs for: 8m).
# peak 91 at 02:15Z, fill 22.8/min, drain 13.0/min -> 10 samples above 5 (9m pending vs for: 20m).
- name: nightly burst 2026-09-25 — recorder purge, benign, self-clearing
interval: 1m
input_series:
@@ -268,37 +176,17 @@ tests:
- eval_time: 7m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:15Z, backlog 91
- eval_time: 7m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:17Z, backlog 65
- eval_time: 9m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:17Z, backlog 65
- eval_time: 9m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:21Z, backlog 13
- eval_time: 13m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:21Z, backlog 13
- eval_time: 13m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:23Z, backlog 0
- eval_time: 15m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:23Z, backlog 0
- eval_time: 15m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 2026-09-26: the nightly Home Assistant recorder purge at 04:12 local.
# peak 113 at 02:15Z, fill 28.5/min, drain 14.1/min -> 11 samples above 5 (10m pending vs for: 15m), 5 above 64 (4m pending vs for: 8m).
# peak 113 at 02:15Z, fill 28.5/min, drain 14.1/min -> 11 samples above 5 (10m pending vs for: 20m).
- name: nightly burst 2026-09-26 — recorder purge, benign, self-clearing
interval: 1m
input_series:
@@ -314,61 +202,23 @@ tests:
- eval_time: 7m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:15Z, backlog 113
- eval_time: 7m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:18Z, backlog 71
- eval_time: 10m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:18Z, backlog 71
- eval_time: 10m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:22Z, backlog 14
- eval_time: 14m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:22Z, backlog 14
- eval_time: 14m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:24Z, backlog 0
- eval_time: 16m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:24Z, backlog 0
- eval_time: 16m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# ---------------------------------------------------------------------
# 8. THE ADVERSARIAL ENVELOPE. A night that did not happen, built from
# the worst fill (39.7/min, 09-23), the highest peak (119, 09-23) and
# the slowest drain (13.0/min, 09-25) in the week. Inside what the
# cluster has demonstrated, worse than anything it actually did.
#
# This is where the two `for` windows get measured for margin rather
# than asserted about. Margin is PENDING time, which is one less than
# the run length — an alert goes pending on the first true evaluation
# and fires at activeAt + for, so 6 consecutive samples above 64
# accumulate 5 minutes, not 6:
#
# above 5: 11 samples -> 10m pending vs `for: 15m` -> 5m margin
# above 64: 6 samples -> 5m pending vs `for: 8m` -> 3m margin
#
# The worst MEASURED night accumulates 4m above 64 (5 samples, 09-20
# and 09-23), so the envelope is one minute tighter than anything that
# actually happened. 3 minutes is the number to defend if anyone
# proposes lowering `for: 8m` — and mutations.txt:surge-for-5m is the
# control that makes this case load-bearing rather than decorative: at
# `for: 5m` the surge rule is still silent on all seven real nights and
# fires only here. Delete this case and that mutation stops being
# caught.
# the slowest drain (13.0/min, 09-25) in the week. 11 samples above 5,
# 10m pending against `for: 20m`.
# ---------------------------------------------------------------------
# Synthetic: max fill 39.7 + max peak 119 + min drain 13.0.
# peak 119 at 02:15Z, fill 39.7/min, drain 13.0/min -> 11 samples above 5 (10m pending vs for: 15m), 6 above 64 (5m pending vs for: 8m).
# peak 119 at 02:15Z, fill 39.7/min, drain 13.0/min -> 11 samples above 5 (10m pending vs for: 20m).
- name: adversarial envelope — worst measured fill and peak, slowest drain
interval: 1m
input_series:
@@ -384,98 +234,94 @@ tests:
- eval_time: 7m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:15Z, backlog 119
- eval_time: 7m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:19Z, backlog 67
- eval_time: 11m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:19Z, backlog 67
- eval_time: 11m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:23Z, backlog 15
- eval_time: 15m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:23Z, backlog 15
- eval_time: 15m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# 02:26Z, backlog 0
- eval_time: 18m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:26Z, backlog 0
- eval_time: 18m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# ---------------------------------------------------------------------
# 9. THE FAILURE BOTH RULES EXIST FOR: an archiver that stopped with
# 70 segments (1.1 GiB) queued. Not a burst — it does not drain.
# Surge fires first (8m after the backlog crosses 64), the
# load-bearing rule 7 minutes later (15m after it crosses 5). Both
# assertions bracket the transition: one minute early nothing is
# 9. THE WORST NIGHT ON RECORD, 2026-09-11, as raw 30s samples (see
# WORST_NIGHT in the generator). Peak 141, 26 samples above 5 = 12.5m
# of true expression. At `evaluation_interval: 1m` the rule sees it
# true from 02:13Z to 02:25Z: 12m pending against `for: 20m`,
# 8m of margin. This is the case that makes the margin
# load-bearing: at `for: 12m` it fires at 02:25Z, and nothing else in
# the suite notices (mutations.txt:backlog-for-12m).
# ---------------------------------------------------------------------
- name: worst night on record 2026-09-11 — peak 141, raw samples
interval: 30s
input_series:
- series: 'cnpg_collector_pg_wal_archive_status{namespace="home-assistant",pod="ha-pg-1",container="postgres",role="primary",value="ready"}'
# 02:08:00Z .. 02:47:00Z, one sample per 30s
values: '0 0 0 0 0 0 0 0 0 28 53 80 110 141 136 133 130 125 117 117 115 112 102 91 81 75 68 60 52 45 37 29 22 15 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0'
- series: 'cnpg_collector_pg_wal_archive_status{namespace="home-assistant",pod="ha-pg-1",container="postgres",role="primary",value="done"}'
values: '148000 148007 148014 148021 148028 148035 148042 148049 148056 148063 148070 148077 148084 148091 148098 148105 148112 148119 148126 148133 148140 148147 148154 148161 148168 148175 148182 148189 148196 148203 148210 148217 148224 148231 148238 148245 148252 148259 148266 148273 148280 148287 148294 148301 148308 148315 148322 148329 148336 148343 148350 148357 148364 148371 148378 148385 148392 148399 148406 148413 148420 148427 148434 148441 148448 148455 148462 148469 148476 148483 148490 148497 148504 148511 148518 148525 148532 148539 148546'
alert_rule_test:
# 02:14Z, backlog 110
- eval_time: 6m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:25Z, backlog 8
- eval_time: 17m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# 02:47Z, backlog 0
- eval_time: 39m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
# ---------------------------------------------------------------------
# 10. THE FAILURE THE RULE EXISTS FOR: an archiver that stopped with
# 70 segments (1.1 GiB) queued. Not a burst — it does not drain. The
# backlog crosses 5 at t=5m, so `for: 20m` elapses at t=25m.
# The assertions bracket the transition: one minute early nothing is
# firing, on the minute it is.
# ---------------------------------------------------------------------
- name: stalled archiver at 70 segments — both rules must fire
- name: stalled archiver at 70 segments — must fire
interval: 1m
input_series:
- series: 'cnpg_collector_pg_wal_archive_status{namespace="home-assistant",pod="ha-pg-1",container="postgres",role="primary",value="ready"}'
values: '0 0 0 0 0 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70'
- series: 'cnpg_collector_pg_wal_archive_status{namespace="home-assistant",pod="ha-pg-1",container="postgres",role="primary",value="done"}'
# Flat, because a stalled archiver archives nothing. The rules do
# Flat, because a stalled archiver archives nothing. The rule does
# not read this; it is here so the input stays realistic.
values: '148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000 148000'
alert_rule_test:
# Backlog crosses 64 at t=5m, so `for: 8m` elapses at t=13m.
- eval_time: 12m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
- eval_time: 13m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts:
# No `role` label: proof that `max by (namespace, pod)`
# aggregated it away. See mutations.txt:no-max-by.
- exp_labels:
severity: warning
namespace: home-assistant
pod: ha-pg-1
exp_annotations:
summary: "CNPG WAL archiving cannot keep up on home-assistant/ha-pg-1"
description: "70 WAL segments (>1 GiB) have been queued for archiving for 8 minutes, which is longer than a healthy archiver needs to clear that much — from a backlog of 119 it takes under 5. Point-in-time recovery is degraded for everything after the last archived segment, and pg_wal grows against the PVC's free space until it clears. Start with the archiver: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`, and check whether its ObjectStore sets `wal.maxParallel` — unset means one segment at a time, a ceiling of about 14 segments/min (REN-129)."
# Backlog crosses 5 at t=5m, so `for: 15m` elapses at t=20m.
- eval_time: 19m
- eval_time: 24m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
- eval_time: 20m
- eval_time: 25m
alertname: CNPGWalArchiveBacklog
exp_alerts:
# No `role` label: proof that `max by (namespace, pod)` aggregated it away. See mutations.txt:no-max-by.
- exp_labels:
severity: warning
namespace: home-assistant
pod: ha-pg-1
exp_annotations:
summary: "CNPG WAL archiving is falling behind on home-assistant/ha-pg-1"
description: "70 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
description: "70 WAL segments have been waiting to archive for over 20 minutes. NOTE ON TIMING: a nightly write burst on ha-pg-1 at 02:14Z (04:14 local) is normal and drains itself within about 13 minutes, and this rule is tuned to stay silent through it — so if this fired, the backlog did NOT clear and the archiver is stuck. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
# ---------------------------------------------------------------------
# 10. THE STALL THE SURGE RULE CANNOT SEE: 12 segments, stuck. Under
# 1 GiB forever, so the surge rule is right to stay silent — and this
# is exactly the shape that makes the >5 rule load-bearing rather than
# a slower copy of it. Point-in-time recovery is just as broken at 12
# segments as at 70.
# 11. THE STALL A DEPTH THRESHOLD CANNOT SEE: 8 segments, stuck. It
# would never reach any number tuned above the nightly envelope, and
# point-in-time recovery is just as broken at 8 segments as at 70. This
# is why REN-152 keyed the rule on persistence and retired the depth rule.
# ---------------------------------------------------------------------
- name: low stall at 12 segments — only the >5 rule may fire
- name: low stall at 8 segments — must fire
interval: 1m
input_series:
- series: 'cnpg_collector_pg_wal_archive_status{namespace="home-assistant",pod="ha-pg-1",container="postgres",role="primary",value="ready"}'
values: '0 0 0 0 0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12'
values: '0 0 0 0 0 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8'
alert_rule_test:
- eval_time: 20m
- eval_time: 24m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
- eval_time: 25m
alertname: CNPGWalArchiveBacklog
exp_alerts:
- exp_labels:
@@ -484,14 +330,10 @@ tests:
pod: ha-pg-1
exp_annotations:
summary: "CNPG WAL archiving is falling behind on home-assistant/ha-pg-1"
description: "12 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
# 34 minutes at 12 segments and the surge rule is still quiet.
- eval_time: 39m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
description: "8 WAL segments have been waiting to archive for over 20 minutes. NOTE ON TIMING: a nightly write burst on ha-pg-1 at 02:14Z (04:14 local) is normal and drains itself within about 13 minutes, and this rule is tuned to stay silent through it — so if this fired, the backlog did NOT clear and the archiver is stuck. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
# ---------------------------------------------------------------------
# 11. PINNED AT EXACTLY 5 for the whole window. `> 5` is strict, so
# 12. PINNED AT EXACTLY 5 for the whole window. `> 5` is strict, so
# this is silence. A rule written `>= 5` would page on it, and a rule
# that had lost its `value="ready"` selector would page on the `done`
# counter regardless of what `ready` does — which is what the second
@@ -508,19 +350,16 @@ tests:
- eval_time: 39m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
- eval_time: 39m
alertname: CNPGWalArchiveBacklogSurge
exp_alerts: []
# ---------------------------------------------------------------------
# 12. FAILOVER DURING A STALL — the case `max by (namespace, pod)` was
# 13. FAILOVER DURING A STALL — the case `max by (namespace, pod)` was
# added for. The backlog starts at t=5m on the primary; at t=11m the
# instance is promoted and `role` changes, which is a NEW SERIES to
# Prometheus and restarts the `for` timer on the raw expression.
# Aggregating `role` away keeps one continuous series, so the page
# still lands 15m after the backlog started (t=20m) rather than 15m
# after the failover. Without `max by` this case is silent at t=20m —
# see mutations.txt:no-max-by.
# still lands 20m after the backlog started (t=25m) rather
# than 20m after the failover. Without `max by` this case is
# silent at t=25m — see mutations.txt:no-max-by.
# ---------------------------------------------------------------------
- name: role flip mid-stall — for timer must not restart
interval: 1m
@@ -532,10 +371,10 @@ tests:
# Starts at t=11m. `_` is a gap, not a zero.
values: '_ _ _ _ _ _ _ _ _ _ _ 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70'
alert_rule_test:
- eval_time: 19m
- eval_time: 24m
alertname: CNPGWalArchiveBacklog
exp_alerts: []
- eval_time: 20m
- eval_time: 25m
alertname: CNPGWalArchiveBacklog
exp_alerts:
- exp_labels:
@@ -544,10 +383,10 @@ tests:
pod: ha-pg-1
exp_annotations:
summary: "CNPG WAL archiving is falling behind on home-assistant/ha-pg-1"
description: "70 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
description: "70 WAL segments have been waiting to archive for over 20 minutes. NOTE ON TIMING: a nightly write burst on ha-pg-1 at 02:14Z (04:14 local) is normal and drains itself within about 13 minutes, and this rule is tuned to stay silent through it — so if this fired, the backlog did NOT clear and the archiver is stuck. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
# ---------------------------------------------------------------------
# 13. ONE STALLED INSTANCE AMONG HEALTHY ONES. There are 12 CNPG
# 14. ONE STALLED INSTANCE AMONG HEALTHY ONES. There are 12 CNPG
# instances in this cluster. `by (namespace, pod)` has to keep them
# apart: exactly one alert, naming the pod that is actually stuck, so
# the 04:00 reader is not sent to look at the wrong Postgres.
@@ -562,7 +401,7 @@ tests:
- series: 'cnpg_collector_pg_wal_archive_status{namespace="immich",pod="immich-pg-1",container="postgres",role="primary",value="ready"}'
values: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
alert_rule_test:
- eval_time: 20m
- eval_time: 25m
alertname: CNPGWalArchiveBacklog
exp_alerts:
- exp_labels:
@@ -571,10 +410,10 @@ tests:
pod: ha-pg-1
exp_annotations:
summary: "CNPG WAL archiving is falling behind on home-assistant/ha-pg-1"
description: "70 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
description: "70 WAL segments have been waiting to archive for over 20 minutes. NOTE ON TIMING: a nightly write burst on ha-pg-1 at 02:14Z (04:14 local) is normal and drains itself within about 13 minutes, and this rule is tuned to stay silent through it — so if this fired, the backlog did NOT clear and the archiver is stuck. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`."
# ---------------------------------------------------------------------
# 14. THE EPOCH-ZERO GUARD on CNPGBackupFailed. The metric is a unix
# 15. THE EPOCH-ZERO GUARD on CNPGBackupFailed. The metric is a unix
# timestamp and reads 0 when no failure was ever recorded, so the rule
# carries a `> 0` guard to stop that default being read as "failed in
# 1970". Held at 0 for the whole window: silence. Nothing else in this
@@ -0,0 +1,115 @@
# promtool test rules for prometheusrule-external-secrets.yaml.
#
# Run by the `promtool` step of .woodpecker/ci-manifests-test.yml through
# scripts/ci/promtool-rules.sh, which strips `spec:` from the manifest into a
# mirrored tree — hence `../` below, resolved from this file's directory. See
# README.md here. The negative controls for this suite are the `eso-*` entries
# in mutations.txt.
#
# WHAT IT IS FOR. Every claim in the rule file that a reviewer would otherwise
# have to take on trust is asserted here instead: that the tombstone series does
# not alert, that `for: 15m` really is 15m, that the annotation names the
# ExternalSecret's own namespace and not the controller's, and that `max`
# survives a two-pod scrape where `sum` does not.
#
# THE REJECTED FORM, for the record. REN-100 and ESO's shipped dashboard both
# use `sum(...) by (namespace, name) == 1`. Run against the identical input
# series below, that expression produces exactly one alert,
# {namespace="external-secrets", name="gitea-db"} — the wrong namespace on the
# one it catches, and nothing at all for monitoring/loki-basic-auth, whose two
# scraped pods sum to 2 and stop matching `== 1`. Both defects, one expression.
rule_files:
- ../prometheusrule-external-secrets.yaml
evaluation_interval: 1m
tests:
# Series shapes copied from the live cluster after #994 landed: the metric's
# own `namespace` has already been shadowed to `exported_namespace` by the
# PodMonitor's target label, and `namespace` is the controller pod's.
- interval: 1m
input_series:
# A healthy ExternalSecret. ESO writes BOTH polarities of the Ready
# condition on every reconcile, the inactive one at 0 — which is why the
# rule needs `== 1` and not a bare selector.
- series: 'externalsecret_status_condition{condition="Ready",status="True",name="uptime-robot-api-key",exported_namespace="uptime-monitor",namespace="external-secrets",job="monitoring/external-secrets",pod="external-secrets-56c649799b-t65gf"}'
values: '1+0x60'
- series: 'externalsecret_status_condition{condition="Ready",status="False",name="uptime-robot-api-key",exported_namespace="uptime-monitor",namespace="external-secrets",job="monitoring/external-secrets",pod="external-secrets-56c649799b-t65gf"}'
values: '0+0x60'
# Starts failing at t=10m and stays failed.
- series: 'externalsecret_status_condition{condition="Ready",status="False",name="gitea-db",exported_namespace="gitea",namespace="external-secrets",job="monitoring/external-secrets",pod="external-secrets-56c649799b-t65gf"}'
values: '0+0x9 1+0x50'
- series: 'externalsecret_status_condition{condition="Ready",status="True",name="gitea-db",exported_namespace="gitea",namespace="external-secrets",job="monitoring/external-secrets",pod="external-secrets-56c649799b-t65gf"}'
values: '1+0x9 0+0x50'
# Tombstone left behind for an ExternalSecret that no longer exists. Held
# at 1 forever until the controller restarts, so a rule that matched
# `condition!="Ready"` or ignored `status` would page on it every day.
- series: 'externalsecret_status_condition{condition="Deleted",status="False",name="wiki-index-basic-auth",exported_namespace="ai",namespace="external-secrets",job="monitoring/external-secrets",pod="external-secrets-56c649799b-t65gf"}'
values: '1+0x60'
# The same failing ExternalSecret reported by TWO controller pods, as
# happens for the seconds of a Deployment rollout when Prometheus still
# has the old target and already has the new one.
- series: 'externalsecret_status_condition{condition="Ready",status="False",name="loki-basic-auth",exported_namespace="monitoring",namespace="external-secrets",job="monitoring/external-secrets",pod="external-secrets-56c649799b-t65gf"}'
values: '0+0x9 1+0x50'
- series: 'externalsecret_status_condition{condition="Ready",status="False",name="loki-basic-auth",exported_namespace="monitoring",namespace="external-secrets",job="monitoring/external-secrets",pod="external-secrets-7d4f9c6b88-qq2xv"}'
values: '0+0x9 1+0x50'
alert_rule_test:
# 5m into the failure: pending, not firing. Asserts the window is real —
# a `for:` accidentally set to 0 passes every other case here and fails
# only this one.
- eval_time: 15m
alertname: ExternalSecretSyncFailing
exp_alerts: []
# 20m into the failure. Both failing ExternalSecrets fire, ONCE each; the
# healthy one and the tombstone stay silent. The annotations are asserted
# in full because the whole point of REN-103's label finding is that the
# text names `gitea`, not `external-secrets`.
- eval_time: 30m
alertname: ExternalSecretSyncFailing
exp_alerts:
- exp_labels:
severity: warning
exported_namespace: gitea
name: gitea-db
exp_annotations:
summary: "ExternalSecret gitea/gitea-db is not syncing"
description: "ESO has been unable to sync this ExternalSecret for 15 minutes. The Secret it manages still holds its last successfully synced value, so consumers keep working — what breaks is that a rotation at the provider no longer propagates, which surfaces much later as a credential that stopped being accepted. Get the reason with `kubectl -n gitea get externalsecret gitea-db -o jsonpath='{.status.conditions}'`; the common causes are a key that was renamed or removed in OpenBao, a ClusterSecretStore that cannot authenticate, and a target Secret owned by something else."
- exp_labels:
severity: warning
exported_namespace: monitoring
name: loki-basic-auth
exp_annotations:
summary: "ExternalSecret monitoring/loki-basic-auth is not syncing"
description: "ESO has been unable to sync this ExternalSecret for 15 minutes. The Secret it manages still holds its last successfully synced value, so consumers keep working — what breaks is that a rotation at the provider no longer propagates, which surfaces much later as a credential that stopped being accepted. Get the reason with `kubectl -n monitoring get externalsecret loki-basic-auth -o jsonpath='{.status.conditions}'`; the common causes are a key that was renamed or removed in OpenBao, a ClusterSecretStore that cannot authenticate, and a target Secret owned by something else."
# Metrics are present, so the dead-man's-switch stays quiet.
- eval_time: 30m
alertname: ExternalSecretMetricsMissing
exp_alerts: []
# The scrape disappears entirely: PodMonitor deleted, selector broken by a
# chart bump, or the `monitoring` ingress grant reverted out of
# external-secrets-ns.yaml. ExternalSecretSyncFailing cannot fire on series
# that do not exist — this is the case that made REN-103 necessary, so it is
# the one the dead-man's-switch has to cover.
- interval: 1m
input_series:
- series: 'up{job="monitoring/external-secrets"}'
values: '0+0x60'
alert_rule_test:
- eval_time: 30m
alertname: ExternalSecretSyncFailing
exp_alerts: []
- eval_time: 30m
alertname: ExternalSecretMetricsMissing
exp_alerts:
- exp_labels:
severity: warning
exp_annotations:
summary: "No ExternalSecret metrics are reaching Prometheus"
description: "`externalsecret_status_condition` has no series. Either the ESO controller is gone or its scrape stopped being collected, and ExternalSecretSyncFailing is blind for as long as this is true. Check the PodMonitor `monitoring/external-secrets` still selects the controller pods, and that external-secrets-ns.yaml still admits `monitoring` on TCP/8080."
@@ -63,6 +63,25 @@ NIGHTS = [
# has demonstrated it can do. Nothing here is extrapolated past the measurements.
ENVELOPE = ("envelope", 119, "02:15", 39.7, 13.0, None)
# The worst night in Prometheus' 27-night retention (2026-08-30..09-26):
# 2026-09-11, peak 141, the longest excursion above 5 on record. Not rebuilt
# from a model like NIGHTS — these are the raw samples, read back through the
# API server's services/proxy with
# max by (namespace, pod) (cnpg_collector_pg_wal_archive_status{
# value="ready", pod="ha-pg-1"})
# over 02:08:00Z..02:47:00Z at the real 30s scrape step (REN-152). 26
# consecutive samples above 5 = 12.5 minutes pending, which is the number the
# `for: 20m` margin is measured against, and why mutations.txt:backlog-for-12m
# is caught here and nowhere else.
WORST_NIGHT = ("2026-09-11", [
0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 53, 80, 110, 141, 136, 133, 130, 125, 117,
117, 115, 112, 102, 91, 81, 75, 68, 60, 52, 45, 37, 29, 22, 15, 8, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
])
FOR_MIN = 20 # `for:` on CNPGWalArchiveBacklog, in minutes
# Series labels. `container`, `role` and `instance` are on the real series and
# are carried here on purpose: they are what `max by (namespace, pod)` has to
# aggregate away, and a test whose input is already aggregated cannot see whether
@@ -185,10 +204,9 @@ def eval_minutes(vals):
run above it (the moment maximum pending time has accumulated). Plus the
peak, plus two minutes after the backlog has settled back to 0."""
picks = set()
for thr in (5, 64):
_, last = longest_run_above(vals, thr)
if last is not None:
picks.add(last)
_, last = longest_run_above(vals, 5)
if last is not None:
picks.add(last)
picks.add(max(range(len(vals)), key=lambda i: vals[i]))
settled = next(
(i for i in range(len(vals) - 1, -1, -1) if vals[i] > 0),
@@ -209,13 +227,11 @@ def burst_case(name, date, peak, peak_min_s, fill, drain, why):
peak_min = parse_hhmm(peak_min_s)
vals = trace(peak, peak_min, fill, drain)
n5, _ = longest_run_above(vals, 5)
n64, _ = longest_run_above(vals, 64)
w(f" # {why}")
w(
f" # peak {peak} at {peak_min_s}Z, fill {fill}/min, drain {drain}/min"
f" -> {n5} samples above 5 ({pending_minutes(vals, 5)}m pending vs"
f" for: 15m), {n64} above 64 ({pending_minutes(vals, 64)}m pending vs"
f" for: 8m)."
f" for: {FOR_MIN}m)."
)
w(f" - name: {name}")
w(" interval: 1m")
@@ -230,13 +246,47 @@ def burst_case(name, date, peak, peak_min_s, fill, drain, why):
w(" alert_rule_test:")
for i in eval_minutes(vals):
clock = hhmm(T0 + i)
for alert in ("CNPGWalArchiveBacklog", "CNPGWalArchiveBacklogSurge"):
w(f" # {clock}Z, backlog {vals[i]}")
w(f" - eval_time: {i}m")
w(f" alertname: {alert}")
w(" exp_alerts: []")
w(f" # {clock}Z, backlog {vals[i]}")
w(f" - eval_time: {i}m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts: []")
w("")
return vals, n5, n64
return vals, n5
def desc(n, pod=POD, ns=NS):
"""The rule's `description` as promtool renders it for `n` segments."""
return (
f"{n} WAL segments have been waiting to archive for over {FOR_MIN} minutes."
" NOTE ON TIMING: a nightly write burst on ha-pg-1 at 02:14Z (04:14 local)"
" is normal and drains itself within about 13 minutes, and this rule is"
" tuned to stay silent through it — so if this fired, the backlog did NOT"
" clear and the archiver is stuck. Point-in-time recovery is broken for"
" anything after the last archived segment, and pg_wal will grow until the"
" PVC fills. Check the barman-cloud sidecar logs and the ObjectStore"
f" credentials: `kubectl -n {ns} logs {pod} -c plugin-barman-cloud`."
)
def firing(eval_time, n, pod=POD, ns=NS, note=None):
w(f" - eval_time: {eval_time}")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts:")
if note:
w(f" # {note}")
w(" - exp_labels:")
w(" severity: warning")
w(f" namespace: {ns}")
w(f" pod: {pod}")
w(" exp_annotations:")
w(f' summary: "CNPG WAL archiving is falling behind on {ns}/{pod}"')
w(f' description: "{desc(n, pod, ns)}"')
def silent(eval_time, alert="CNPGWalArchiveBacklog"):
w(f" - eval_time: {eval_time}")
w(f" alertname: {alert}")
w(" exp_alerts: []")
def main():
@@ -251,23 +301,22 @@ def main():
assert_window_covers_bursts()
if args.report:
# `pend` columns are what the `for` windows are actually compared
# against; see pending_minutes(). `>5 pub` is Iris's published column
# and is the only number here that is not derived by this script.
# `pend` is what the `for` window is actually compared against; see
# pending_minutes(). `>5 pub` is Iris's published column and is the
# only number here that is not derived by this script.
print(f"{'night':12} {'peak':>5} {'fill':>6} {'drain':>6} "
f"{'>5 pub':>7} {'>5 n':>6} {'>5 pend':>8} "
f"{'>64 n':>6} {'>64 pend':>9}")
f"{'>5 pub':>7} {'>5 n':>6} {'>5 pend':>8}")
for date, peak, pm, fill, drain, dur in NIGHTS + [ENVELOPE]:
vals = trace(peak, parse_hhmm(pm), fill, drain)
n5, _ = longest_run_above(vals, 5)
n64, _ = longest_run_above(vals, 64)
print(f"{date:12} {peak:5} {fill:6} {drain:6} "
f"{('-' if dur is None else dur):>7} {n5:>6} "
f"{pending_minutes(vals, 5):>8} "
f"{n64:>6} {pending_minutes(vals, 64):>9}")
f"{pending_minutes(vals, 5):>8}")
wn, _ = longest_run_above(WORST_NIGHT[1], 5)
print(f"{WORST_NIGHT[0]:12} {max(WORST_NIGHT[1]):5} {'raw':>6} {'30s':>6} "
f"{'-':>7} {wn:>6} {max(0, wn - 1) / 2:>8}")
print()
print("for: 15m on >5 must exceed every '>5 pend' above.")
print("for: 8m on >64 must exceed every '>64 pend' above.")
print(f"for: {FOR_MIN}m on >5 must exceed every '>5 pend' above.")
return 0
w("# GENERATED by generate-cnpg-backup-test.py — see README.md in this")
@@ -275,9 +324,10 @@ def main():
w("#")
w("# Unit tests for kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml.")
w("# Every assertion below is either one of Iris's seven measured nights")
w("# (REN-129) rebuilt from its published (peak, fill, drain) numbers, an")
w("# (REN-129) rebuilt from its published (peak, fill, drain) numbers, the")
w("# worst night in Prometheus' retention as raw samples (REN-152), an")
w("# adversarial combination of the extremes of those numbers, or a failure")
w("# this cluster has not had but the rules exist to catch.")
w("# this cluster has not had but the rule exists to catch.")
w("#")
w("# `rule_files` entries are resolved RELATIVE TO THIS FILE'S DIRECTORY, not")
w("# to the working directory promtool was invoked from — promtool joins")
@@ -296,14 +346,13 @@ def main():
w("")
w("tests:")
w(" # ---------------------------------------------------------------------")
w(" # 1-7. THE SEVEN MEASURED NIGHTS. Both rules must stay silent through")
w(" # every one of them. This is the half of the suite that has already")
w(" # caught something: the surge rule shipped for review at `for: 2m` and")
w(" # fires here on 6 of these 7 nights (mutations.txt:surge-for-2m).")
w(" # 1-7. THE SEVEN MEASURED NIGHTS. The rule must stay silent through")
w(" # every one of them. The retired depth rule (`> 64`) shipped for review")
w(" # at `for: 2m` and fired on 6 of these 7 nights; REN-152 removed it.")
w(" # ---------------------------------------------------------------------")
checks = []
for date, peak, pm, fill, drain, dur in NIGHTS:
vals, n5, n64 = burst_case(
vals, n5 = burst_case(
f"nightly burst {date} — recorder purge, benign, self-clearing",
date, peak, pm, fill, drain,
f"{date}: the nightly Home Assistant recorder purge at 04:12 local.",
@@ -313,26 +362,8 @@ def main():
w(" # ---------------------------------------------------------------------")
w(" # 8. THE ADVERSARIAL ENVELOPE. A night that did not happen, built from")
w(" # the worst fill (39.7/min, 09-23), the highest peak (119, 09-23) and")
w(" # the slowest drain (13.0/min, 09-25) in the week. Inside what the")
w(" # cluster has demonstrated, worse than anything it actually did.")
w(" #")
w(" # This is where the two `for` windows get measured for margin rather")
w(" # than asserted about. Margin is PENDING time, which is one less than")
w(" # the run length — an alert goes pending on the first true evaluation")
w(" # and fires at activeAt + for, so 6 consecutive samples above 64")
w(" # accumulate 5 minutes, not 6:")
w(" #")
w(" # above 5: 11 samples -> 10m pending vs `for: 15m` -> 5m margin")
w(" # above 64: 6 samples -> 5m pending vs `for: 8m` -> 3m margin")
w(" #")
w(" # The worst MEASURED night accumulates 4m above 64 (5 samples, 09-20")
w(" # and 09-23), so the envelope is one minute tighter than anything that")
w(" # actually happened. 3 minutes is the number to defend if anyone")
w(" # proposes lowering `for: 8m` — and mutations.txt:surge-for-5m is the")
w(" # control that makes this case load-bearing rather than decorative: at")
w(" # `for: 5m` the surge rule is still silent on all seven real nights and")
w(" # fires only here. Delete this case and that mutation stops being")
w(" # caught.")
w(" # the slowest drain (13.0/min, 09-25) in the week. 11 samples above 5,")
w(" # 10m pending against `for: 20m`.")
w(" # ---------------------------------------------------------------------")
burst_case(
"adversarial envelope — worst measured fill and peak, slowest drain",
@@ -340,92 +371,80 @@ def main():
why="Synthetic: max fill 39.7 + max peak 119 + min drain 13.0.",
)
# ---- 9. stalled archiver, above the surge threshold -------------------
stalled = [0] * 5 + [70] * 35
date, raw = WORST_NIGHT
wn, wlast = longest_run_above(raw, 5)
peak_i = max(range(len(raw)), key=lambda i: raw[i])
w(" # ---------------------------------------------------------------------")
w(" # 9. THE FAILURE BOTH RULES EXIST FOR: an archiver that stopped with")
w(" # 70 segments (1.1 GiB) queued. Not a burst — it does not drain.")
w(" # Surge fires first (8m after the backlog crosses 64), the")
w(" # load-bearing rule 7 minutes later (15m after it crosses 5). Both")
w(" # assertions bracket the transition: one minute early nothing is")
w(f" # 9. THE WORST NIGHT ON RECORD, {date}, as raw 30s samples (see")
w(" # WORST_NIGHT in the generator). Peak 141, 26 samples above 5 = 12.5m")
w(" # of true expression. At `evaluation_interval: 1m` the rule sees it")
w(f" # true from 02:13Z to 02:25Z: 12m pending against `for: {FOR_MIN}m`,")
w(f" # {FOR_MIN - 12}m of margin. This is the case that makes the margin")
w(" # load-bearing: at `for: 12m` it fires at 02:25Z, and nothing else in")
w(" # the suite notices (mutations.txt:backlog-for-12m).")
w(" # ---------------------------------------------------------------------")
w(f" - name: worst night on record {date} — peak 141, raw samples")
w(" interval: 30s")
w(" input_series:")
w(f" - series: '{labels()}'")
w(f" # {hhmm(T0)}:00Z .. {hhmm(T0 + 39)}:00Z, one sample per 30s")
w(f" values: '{fmt(raw)}'")
w(f" - series: '{labels(value='done')}'")
w(f" values: '{fmt(counter(148_000, 7, len(raw)))}'")
w(" alert_rule_test:")
for i in (peak_i, wlast, len(raw) - 1):
# eval times in whole minutes: the group evaluates on the minute.
m = (i // 2)
w(f" # {hhmm(T0 + m)}Z, backlog {raw[m * 2]}")
silent(f"{m}m")
w("")
# ---- 10. stalled archiver, well above threshold ------------------------
stalled = [0] * 5 + [70] * 35
fire_at = 5 + FOR_MIN
w(" # ---------------------------------------------------------------------")
w(" # 10. THE FAILURE THE RULE EXISTS FOR: an archiver that stopped with")
w(" # 70 segments (1.1 GiB) queued. Not a burst — it does not drain. The")
w(f" # backlog crosses 5 at t=5m, so `for: {FOR_MIN}m` elapses at t={fire_at}m.")
w(" # The assertions bracket the transition: one minute early nothing is")
w(" # firing, on the minute it is.")
w(" # ---------------------------------------------------------------------")
w(" - name: stalled archiver at 70 segments — both rules must fire")
w(" - name: stalled archiver at 70 segments — must fire")
w(" interval: 1m")
w(" input_series:")
w(f" - series: '{labels()}'")
w(f" values: '{fmt(stalled)}'")
w(f" - series: '{labels(value='done')}'")
w(" # Flat, because a stalled archiver archives nothing. The rules do")
w(" # Flat, because a stalled archiver archives nothing. The rule does")
w(" # not read this; it is here so the input stays realistic.")
w(f" values: '{fmt([148_000] * SAMPLES)}'")
w(" alert_rule_test:")
w(" # Backlog crosses 64 at t=5m, so `for: 8m` elapses at t=13m.")
w(" - eval_time: 12m")
w(" alertname: CNPGWalArchiveBacklogSurge")
w(" exp_alerts: []")
w(" - eval_time: 13m")
w(" alertname: CNPGWalArchiveBacklogSurge")
w(" exp_alerts:")
w(" # No `role` label: proof that `max by (namespace, pod)`")
w(" # aggregated it away. See mutations.txt:no-max-by.")
w(" - exp_labels:")
w(" severity: warning")
w(f" namespace: {NS}")
w(f" pod: {POD}")
w(" exp_annotations:")
w(f' summary: "CNPG WAL archiving cannot keep up on {NS}/{POD}"')
w(" description: \"70 WAL segments (>1 GiB) have been queued for archiving for 8 minutes, which is longer than a healthy archiver needs to clear that much — from a backlog of 119 it takes under 5. Point-in-time recovery is degraded for everything after the last archived segment, and pg_wal grows against the PVC's free space until it clears. Start with the archiver: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`, and check whether its ObjectStore sets `wal.maxParallel` — unset means one segment at a time, a ceiling of about 14 segments/min (REN-129).\"")
w(" # Backlog crosses 5 at t=5m, so `for: 15m` elapses at t=20m.")
w(" - eval_time: 19m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts: []")
w(" - eval_time: 20m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts:")
w(" - exp_labels:")
w(" severity: warning")
w(f" namespace: {NS}")
w(f" pod: {POD}")
w(" exp_annotations:")
w(f' summary: "CNPG WAL archiving is falling behind on {NS}/{POD}"')
w(" description: \"70 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`.\"")
silent(f"{fire_at - 1}m")
firing(f"{fire_at}m", 70, note="No `role` label: proof that `max by (namespace, pod)` "
"aggregated it away. See mutations.txt:no-max-by.")
w("")
# ---- 10. low stall, below the surge threshold -------------------------
low = [0] * 5 + [12] * 35
# ---- 11. low stall ------------------------------------------------------
low = [0] * 5 + [8] * 35
w(" # ---------------------------------------------------------------------")
w(" # 10. THE STALL THE SURGE RULE CANNOT SEE: 12 segments, stuck. Under")
w(" # 1 GiB forever, so the surge rule is right to stay silent — and this")
w(" # is exactly the shape that makes the >5 rule load-bearing rather than")
w(" # a slower copy of it. Point-in-time recovery is just as broken at 12")
w(" # segments as at 70.")
w(" # 11. THE STALL A DEPTH THRESHOLD CANNOT SEE: 8 segments, stuck. It")
w(" # would never reach any number tuned above the nightly envelope, and")
w(" # point-in-time recovery is just as broken at 8 segments as at 70. This")
w(" # is why REN-152 keyed the rule on persistence and retired the depth rule.")
w(" # ---------------------------------------------------------------------")
w(" - name: low stall at 12 segments — only the >5 rule may fire")
w(" - name: low stall at 8 segments — must fire")
w(" interval: 1m")
w(" input_series:")
w(f" - series: '{labels()}'")
w(f" values: '{fmt(low)}'")
w(" alert_rule_test:")
w(" - eval_time: 20m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts:")
w(" - exp_labels:")
w(" severity: warning")
w(f" namespace: {NS}")
w(f" pod: {POD}")
w(" exp_annotations:")
w(f' summary: "CNPG WAL archiving is falling behind on {NS}/{POD}"')
w(" description: \"12 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`.\"")
w(" # 34 minutes at 12 segments and the surge rule is still quiet.")
w(" - eval_time: 39m")
w(" alertname: CNPGWalArchiveBacklogSurge")
w(" exp_alerts: []")
silent(f"{fire_at - 1}m")
firing(f"{fire_at}m", 8)
w("")
# ---- 11. exactly at the threshold ------------------------------------
# ---- 12. exactly at the threshold ------------------------------------
w(" # ---------------------------------------------------------------------")
w(" # 11. PINNED AT EXACTLY 5 for the whole window. `> 5` is strict, so")
w(" # 12. PINNED AT EXACTLY 5 for the whole window. `> 5` is strict, so")
w(" # this is silence. A rule written `>= 5` would page on it, and a rule")
w(" # that had lost its `value=\"ready\"` selector would page on the `done`")
w(" # counter regardless of what `ready` does — which is what the second")
@@ -439,24 +458,19 @@ def main():
w(f" - series: '{labels(value='done')}'")
w(f" values: '{fmt(counter(148_000, 14))}'")
w(" alert_rule_test:")
w(" - eval_time: 39m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts: []")
w(" - eval_time: 39m")
w(" alertname: CNPGWalArchiveBacklogSurge")
w(" exp_alerts: []")
silent("39m")
w("")
# ---- 12. role flip ---------------------------------------------------
# ---- 13. role flip ---------------------------------------------------
w(" # ---------------------------------------------------------------------")
w(" # 12. FAILOVER DURING A STALL — the case `max by (namespace, pod)` was")
w(" # 13. FAILOVER DURING A STALL — the case `max by (namespace, pod)` was")
w(" # added for. The backlog starts at t=5m on the primary; at t=11m the")
w(" # instance is promoted and `role` changes, which is a NEW SERIES to")
w(" # Prometheus and restarts the `for` timer on the raw expression.")
w(" # Aggregating `role` away keeps one continuous series, so the page")
w(" # still lands 15m after the backlog started (t=20m) rather than 15m")
w(" # after the failover. Without `max by` this case is silent at t=20m —")
w(" # see mutations.txt:no-max-by.")
w(f" # still lands {FOR_MIN}m after the backlog started (t={fire_at}m) rather")
w(f" # than {FOR_MIN}m after the failover. Without `max by` this case is")
w(f" # silent at t={fire_at}m — see mutations.txt:no-max-by.")
w(" # ---------------------------------------------------------------------")
w(" - name: role flip mid-stall — for timer must not restart")
w(" interval: 1m")
@@ -468,24 +482,13 @@ def main():
w(" # Starts at t=11m. `_` is a gap, not a zero.")
w(f" values: '{'_ ' * 11}{fmt([70] * 29)}'")
w(" alert_rule_test:")
w(" - eval_time: 19m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts: []")
w(" - eval_time: 20m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts:")
w(" - exp_labels:")
w(" severity: warning")
w(f" namespace: {NS}")
w(f" pod: {POD}")
w(" exp_annotations:")
w(f' summary: "CNPG WAL archiving is falling behind on {NS}/{POD}"')
w(" description: \"70 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`.\"")
silent(f"{fire_at - 1}m")
firing(f"{fire_at}m", 70)
w("")
# ---- 13. one stalled pod among healthy ones --------------------------
# ---- 14. one stalled pod among healthy ones --------------------------
w(" # ---------------------------------------------------------------------")
w(" # 13. ONE STALLED INSTANCE AMONG HEALTHY ONES. There are 12 CNPG")
w(" # 14. ONE STALLED INSTANCE AMONG HEALTHY ONES. There are 12 CNPG")
w(" # instances in this cluster. `by (namespace, pod)` has to keep them")
w(" # apart: exactly one alert, naming the pod that is actually stuck, so")
w(" # the 04:00 reader is not sent to look at the wrong Postgres.")
@@ -500,21 +503,12 @@ def main():
w(f" - series: '{labels(pod='immich-pg-1', ns='immich')}'")
w(f" values: '{fmt([0] * SAMPLES)}'")
w(" alert_rule_test:")
w(" - eval_time: 20m")
w(" alertname: CNPGWalArchiveBacklog")
w(" exp_alerts:")
w(" - exp_labels:")
w(" severity: warning")
w(f" namespace: {NS}")
w(" pod: ha-pg-1")
w(" exp_annotations:")
w(f' summary: "CNPG WAL archiving is falling behind on {NS}/ha-pg-1"')
w(" description: \"70 WAL segments have been waiting to archive for over 15 minutes. Point-in-time recovery is broken for anything after the last archived segment, and pg_wal will grow until the PVC fills. Check the barman-cloud sidecar logs and the ObjectStore credentials: `kubectl -n home-assistant logs ha-pg-1 -c plugin-barman-cloud`.\"")
firing(f"{fire_at}m", 70, pod="ha-pg-1")
w("")
# ---- 14. CNPGBackupFailed --------------------------------------------
# ---- 15. CNPGBackupFailed --------------------------------------------
w(" # ---------------------------------------------------------------------")
w(" # 14. THE EPOCH-ZERO GUARD on CNPGBackupFailed. The metric is a unix")
w(" # 15. THE EPOCH-ZERO GUARD on CNPGBackupFailed. The metric is a unix")
w(" # timestamp and reads 0 when no failure was ever recorded, so the rule")
w(" # carries a `> 0` guard to stop that default being read as \"failed in")
w(" # 1970\". Held at 0 for the whole window: silence. Nothing else in this")
@@ -527,9 +521,7 @@ def main():
w(f" - series: 'cnpg_collector_last_failed_backup_timestamp{{namespace=\"{NS}\",pod=\"{POD}\"}}'")
w(f" values: '{fmt([0] * SAMPLES)}'")
w(" alert_rule_test:")
w(" - eval_time: 39m")
w(" alertname: CNPGBackupFailed")
w(" exp_alerts: []")
silent("39m", "CNPGBackupFailed")
print("\n".join(L))
@@ -28,45 +28,69 @@
# `detected by` notes below are for the reader. The machine check is only "the
# suite must fail"; nothing parses them.
# The defect this whole exercise exists because of. The surge rule was written
# `for: 2m` and reviewed at that value. Six of Iris's seven measured nights
# accumulate 3-4 minutes above 64, so it fires on all six — two owner emails a
# night, 04:16 and 04:22 local, for a backlog that clears itself.
# Detected by: cases 1-7, the measured nights.
surge-for-2m|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|s/^\([[:space:]]*\)for: 8m$/\1for: 2m/
# The margin control, and the only reason case 8 is in the suite. At `for: 5m`
# the surge rule is still silent on all seven REAL nights (worst is 4m pending)
# and fires only on the adversarial envelope (5m pending). Without the envelope
# case, `for: 8m` could be cut to 5m with the suite staying green.
# Detected by: case 8, the adversarial envelope.
surge-for-5m|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|s/^\([[:space:]]*\)for: 8m$/\1for: 5m/
# The margin control, and the only reason case 9 is in the suite. The worst
# night in Prometheus' retention (2026-09-11, peak 141) holds the expression
# true for 12 minutes at a 1m evaluation step, so at `for: 12m` it fires. The
# seven reconstructed nights peak at 10m pending and would stay silent — without
# the raw worst-night case, `for: 20m` could be cut to 12m with the suite green.
# Detected by: case 9, the worst night on record.
backlog-for-12m|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|s/^\([[:space:]]*\)for: 20m$/\1for: 12m/
# The value REN-129 changed, in the direction it changed it from. At 30m the
# load-bearing rule does not page until 35 minutes into a stall that started at
# t=5m, so the assertion at t=20m sees nothing. This is the control that stops
# the 15m being quietly walked back.
# Detected by: cases 9, 10, 12, 13 — every case that expects a page.
backlog-for-30m|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|s/^\([[:space:]]*\)for: 15m$/\1for: 30m/
# rule does not page until 35 minutes into a stall that started at t=5m, so the
# assertion at t=25m sees nothing. This is the control that stops the 20m being
# quietly walked back.
# Detected by: cases 10, 11, 13, 14 — every case that expects a page.
backlog-for-30m|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|s/^\([[:space:]]*\)for: 20m$/\1for: 30m/
# Drop the aggregation, keeping the selector. `role` flips on failover; a
# changed label is a new series to Prometheus and restarts the `for` timer, so
# a backlog that persists across a promotion pages 15m after the promotion
# instead of 15m after the backlog. Scoped to `expr:` lines because
# a backlog that persists across a promotion pages 20m after the promotion
# instead of 20m after the backlog. Scoped to `expr:` lines because
# `max by (namespace, pod)` also appears in this manifest's comments, where
# rewriting it would mutate the documentation and nothing else.
# Detected by: case 12, the role flip.
# Detected by: case 13, the role flip.
no-max-by|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|/^[[:space:]]*expr:/s/max by (namespace, pod) (\(cnpg_collector_pg_wal_archive_status{value="ready"}\))/\1/
# Drop the `value="ready"` selector. The same metric name also carries
# `value="done"`, a monotonic counter in the hundreds of thousands, so both
# rules would fire permanently on every CNPG instance in the cluster. The
# `value="done"`, a monotonic counter in the hundreds of thousands, so the
# rule would fire permanently on every CNPG instance in the cluster. The
# measured-night cases carry that counter series in their input specifically so
# this is detectable rather than a silent no-op.
# Detected by: cases 1-8 and 11 — every case with a `done` series.
# Detected by: cases 1-9 and 12 — every case with a `done` series.
no-value-selector|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|/^[[:space:]]*expr:/s/{value="ready"}//
# Loosen the comparison on the load-bearing rule. `> 5` is strict; `>= 5` pages
# Loosen the comparison. `> 5` is strict; `>= 5` pages
# on a backlog sitting at exactly five segments, which is 80 MiB and normal.
# Detected by: case 11, pinned at exactly 5.
# Detected by: case 12, pinned at exactly 5.
backlog-ge-5|kubernetes/apps/monitoring-rules/prometheusrule-cnpg-backup.yaml|/^[[:space:]]*expr:/s/> 5$/>= 5/
# --- prometheusrule-external-secrets.yaml (REN-103) -------------------------
# Scoped to the ExternalSecretSyncFailing expression with /max by/ or /== 1/
# where it matters: the manifest's comments quote the rejected forms, and
# rewriting those would mutate the documentation and nothing else.
# The window. At 5m the failure that starts at t=10m is already firing at the
# t=15m assertion, which expects pending.
# Detected by: the eval_time 15m case.
eso-for-5m|kubernetes/apps/monitoring-rules/prometheusrule-external-secrets.yaml|s/^\([[:space:]]*\)for: 15m$/\1for: 5m/
# REN-100's aggregation. `sum` over the two-pod rollout case is 2, fails
# `== 1`, and loki-basic-auth never fires.
# Detected by: the eval_time 30m case, loki-basic-auth.
eso-sum-not-max|kubernetes/apps/monitoring-rules/prometheusrule-external-secrets.yaml|s/^\([[:space:]]*\)max by (exported_namespace, name) ($/\1sum by (exported_namespace, name) (/
# The label Argus found shadowed on #994. Grouping by `namespace` names the
# controller's namespace on every alert.
# Detected by: the eval_time 30m case, exp_labels and the rendered summary.
eso-by-namespace|kubernetes/apps/monitoring-rules/prometheusrule-external-secrets.yaml|s/^\([[:space:]]*\)max by (exported_namespace, name) ($/\1max by (namespace, name) (/
# Drop `== 1`. ESO writes the inactive Ready polarity at 0, so every healthy
# ExternalSecret matches the bare selector and fires.
# Detected by: the eval_time 30m case, uptime-robot-api-key.
eso-no-eq-1|kubernetes/apps/monitoring-rules/prometheusrule-external-secrets.yaml|s/^\([[:space:]]*\)) == 1$/\1)/
# Drop the condition selector. The Deleted tombstone is status="False" at 1
# forever, so it pages until the controller restarts.
# Detected by: the eval_time 30m case, wiki-index-basic-auth.
eso-any-condition|kubernetes/apps/monitoring-rules/prometheusrule-external-secrets.yaml|s/^\([[:space:]]*\)externalsecret_status_condition{condition="Ready",status="False"}$/\1externalsecret_status_condition{status="False"}/
@@ -2,6 +2,7 @@ apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: blackbox-exporter
# anchor: namespace
namespace: monitoring
spec:
interval: 30m
@@ -17,7 +17,7 @@ spec:
chart:
spec:
chart: kube-prometheus-stack
version: ">=72.0.0"
version: "91.7.0"
sourceRef:
kind: HelmRepository
name: prometheus-community
@@ -83,6 +83,7 @@ spec:
- name: music
mountPath: /music
readOnly: true
# anchor: kubelet-probes
livenessProbe:
httpGet:
path: /ping
+1
View File
@@ -16,6 +16,7 @@ spec:
paths:
- path: /
pathType: Prefix
# anchor: navidrome-gate
backend:
service:
name: ak-outpost-navidrome-gate
+3
View File
@@ -23,6 +23,7 @@ metadata:
name: lidarr-reconcile
namespace: navidrome
data:
# anchor: reconcile-script
reconcile.sh: |
set -eu
API=http://localhost:8686/api/v1
@@ -111,6 +112,7 @@ spec:
mountPath: /config
- name: music
mountPath: /music
# anchor: kubelet-probes
livenessProbe:
httpGet:
path: /ping
@@ -213,6 +215,7 @@ spec:
paths:
- path: /
pathType: Prefix
# anchor: lidarr-gate
backend:
service:
name: ak-outpost-lidarr-gate
@@ -58,7 +58,8 @@
# aggregation did not already cover them. It does, so none is added:
# `flux-view-flux-system` carries `rbac.authorization.k8s.io/aggregate-to-view:
# "true"` and lists get/list/watch on `*` across all six API groups —
# `../../clusters/homelab/flux-system/gotk-components.yaml:232-254`. The
# the `flux-view-flux-system` ClusterRole in
# `../../clusters/homelab/flux-system/gotk-components.yaml`. The
# aggregation controller merges those rules into `view` itself, so this one
# binding picks up kustomizations, helmreleases, gitrepositories, imagepolicies,
# imagerepositories and imageupdateautomations. Read from git, not from a live
+1 -1
View File
@@ -34,7 +34,7 @@ spec:
type: RuntimeDefault
containers:
- name: paperclip
image: ghcr.io/paperclipai/paperclip:nightly@sha256:9222efbf11863160669e13d5559e6a1be881886dd1758650b74c3993dc3ef2a6 # {"$imagepolicy": "flux-system:paperclip"}
image: ghcr.io/paperclipai/paperclip:nightly@sha256:1da39019a9b48c2b9318a5f037978765d226c8ef6838545fa691f3f8200bccac # {"$imagepolicy": "flux-system:paperclip"}
ports:
- name: http
containerPort: 3100
+1
View File
@@ -1,6 +1,7 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
# anchor: pprl-pg
name: pprl-pg
namespace: paperless
annotations:
+1
View File
@@ -59,6 +59,7 @@ metadata:
spec:
selector:
app.kubernetes.io/name: gotenberg
# anchor: service-port
ports:
- port: 3000
targetPort: http
@@ -11,14 +11,19 @@
# the allow rules of every CNP selecting an endpoint (the same mechanism
# described below). The effective ingress set is this outpost PLUS, on
# every port:
# - the paperless namespace (paperless-ns.yaml:9-11)
# - the database namespace (paperless-ns.yaml:31-33)
# - the monitoring namespace (paperless-ns.yaml:34-36)
# - host / remote-node (paperless-ns.yaml:37-39)
# - the paperless namespace
# ../../infrastructure/network-policies/paperless-ns.yaml#paperless-admit
# - the database namespace
# ../../infrastructure/network-policies/paperless-ns.yaml#database-admit
# - the monitoring namespace
# ../../infrastructure/network-policies/paperless-ns.yaml#monitoring-admit
# - host / remote-node
# ../../infrastructure/network-policies/paperless-ns.yaml#host-admit
# So any pod in database or monitoring can reach this HTTP listener
# directly and set X-Authentik-Username to any value. Do not read this
# rule as the whole boundary. Narrowing is tracked in REN-28.
#
# anchor: cnp-union
# This is a CiliumNetworkPolicy (not a standard NetworkPolicy) so it
# composes additively with the cluster's baseline CNP
# `default-deny-ingress` for the paperless namespace — Cilium's allow
+4
View File
@@ -24,6 +24,7 @@ data:
PAPERLESS_ACCOUNT_DEFAULT_GROUPS: "Familie"
PAPERLESS_URL: "https://paperless.renner.uno"
PAPERLESS_CSRF_TRUSTED_ORIGINS: "https://paperless.renner.uno,https://docs.renner.uno"
# anchor: allowed-hosts
PAPERLESS_ALLOWED_HOSTS: "*"
PAPERLESS_TIME_ZONE: "Europe/Berlin"
PAPERLESS_OCR_LANGUAGE: "deu+eng"
@@ -43,6 +44,7 @@ data:
PAPERLESS_CONSUMER_POLLING_INTERVAL: "10"
PAPERLESS_REDIS: "redis://redis:6379"
PAPERLESS_DBENGINE: "postgresql"
# anchor: db-host
PAPERLESS_DBHOST: "pprl-pg-rw"
PAPERLESS_DBNAME: "paperless"
PAPERLESS_TIKA_ENABLED: "1"
@@ -249,6 +251,7 @@ spec:
# answers, giving that boot 30 * 20s = 10 minutes. Without it the
# 120s liveness delay plus three 30s periods kills the pod 210s in,
# part-way through a migration, and the next boot starts over.
# anchor: http-probes
startupProbe:
httpGet:
path: /accounts/login/
@@ -282,6 +285,7 @@ spec:
capabilities:
drop: ["ALL"]
add: ["CHOWN", "DAC_OVERRIDE", "FOWNER", "SETGID", "SETUID"]
# anchor: bridge-tls-proxy
- name: bridge-tls-proxy
image: alpine/socat:1.8.0.3
args:
+1
View File
@@ -72,6 +72,7 @@ metadata:
spec:
selector:
app.kubernetes.io/name: redis
# anchor: service-port
ports:
- port: 6379
targetPort: redis
+1
View File
@@ -53,6 +53,7 @@ metadata:
spec:
selector:
app.kubernetes.io/name: tika
# anchor: service-port
ports:
- port: 9998
targetPort: http
@@ -36,7 +36,7 @@
# raised — no further PR needed. Until then this object logs one refused POST
# every 300s and nothing else: nothing pages, nothing degrades, and
# `audiobooks.renner.uno` stays covered by its 60s Gatus check
# (apps/gatus/configmap.yaml:163) throughout.
# (Web Service 8 in ../gatus/configmap.yaml#gatus-endpoints) throughout.
#
# REVERT: revert this commit. Flux prunes the object again and, because the
# monitor does not exist to begin with, nothing in UptimeRobot changes.
@@ -72,7 +72,8 @@
# namespace, and the reason is structural rather than a permissions gap:
#
# * `IngressURLSource` has exactly one field, `name` — there is no namespace
# field on it (crd-endpointmonitors.yaml:443-459).
# field on it (crd-endpointmonitors.yaml, schema path
# `spec.urlFrom.ingressRef`).
# * `discoverURLFromRefs` resolves that name against
# `ingressMonitor.Namespace` — the EndpointMonitor's OWN namespace
# (v2.2.13 pkg/kube/util/url.go:71 → :38-40).
@@ -111,19 +112,31 @@
# template.
#
# ---
# NO `alertContacts` YET — AND THIS IS A GAP, NOT AN OVERSIGHT
# `alertContacts` — WIRED TO THE OWNER'S EXISTING CHANNEL (REN-7, REN-138)
#
# `processProviderConfig` ALWAYS appends `&alert_contacts=`, falling back to the
# provider-level value from config.yaml when the CR sets none
# (uptime-monitor.go:240-244). Neither is set today, so these two monitors are
# created with an EMPTY alert-contact list: UptimeRobot will record the outage
# and show it on the page, and will notify nobody.
# (uptime-monitor.go:240-244). Neither was set before this change, so the pilot
# monitors were created notifying nobody.
#
# That is the safe direction to be wrong in for a pilot, but it means REN-7's
# "an alert reaches the owner's existing alert channel" is NOT satisfied by this
# file. Closing it needs the numeric alert-contact id from `getAlertContacts`,
# which needs the API key. Tracked separately; do not read a green pilot as
# proof the alert path works.
# The value below is copied from the account, not chosen: every one of the nine
# hand-made monitors carries exactly these two contacts, at threshold 0 and
# recurrence 0 (read with `getMonitors&alert_contacts=1`, 2026-09-26). So an IMC
# monitor now alerts wherever the owner's existing monitors already alert — no
# new channel, no new recipient. Contact ids from `getAlertContacts`:
#
# 7880965 type 2 (e-mail)
# 8026823 type 13
#
# ORDER MATTERS. `Equal` compares the rendered request strings, and the read-back
# side builds its string from the API's `alert_contacts` array in the order the
# API returns it (uptime-mappers.go:22-29). The API returns 7880965 first, so the
# value is written in that order; reversed, IMC would see a "change" and re-send
# `editMonitor` every 300s forever.
#
# ALERT DELIVERY IS OWNER-VERIFIED, NOT PROVEN HERE. By the owner's ruling on
# REN-138 no test alert is fired from this repo: no broken monitor, no sentinel.
# This file proves the wiring only.
#
# ---
# NO `statusPages` — AND THE EXPERIMENT THAT JUSTIFIED LEAVING IT UNSET IS NOW
@@ -240,7 +253,7 @@ metadata:
spec:
# `https://www.renner.uno` and not `/wp-admin` or `/wp-login.php`: those two
# paths are served by a SECOND Ingress that sits behind the Authentik outpost
# (apps/wordpress/ingress.yaml:50,57). `/` is the ungated one.
# (../wordpress/ingress.yaml#gated-paths). `/` is the ungated one.
url: https://www.renner.uno/
uptimeRobotConfig:
# `http`, not `keyword`. The survey recommends a keyword check here
@@ -254,6 +267,8 @@ spec:
# matches the interval of the nine monitors already in the account. Written
# out rather than left implicit so the value is reviewable here.
interval: 300
# See "alertContacts" in the header: the owner's existing two contacts.
alertContacts: 7880965_0_0-8026823_0_0
---
# Restored by this commit. This object already proved criterion 3 end to end:
# created as id 804092841 at 03:26:27Z, removed as `Monitor Removed` at
@@ -273,8 +288,9 @@ spec:
# explicitly ignored when `spec.url` is set (pkg/kube/util/url.go:31-33).
# `/healthcheck` is ungated, so the check reaches application health rather
# than mere reachability — it is the same endpoint the Gatus check uses
# (apps/gatus/configmap.yaml:163).
# (Web Service 8 in ../gatus/configmap.yaml#gatus-endpoints).
url: https://audiobooks.renner.uno/healthcheck
uptimeRobotConfig:
monitorType: http
interval: 300
alertContacts: 7880965_0_0-8026823_0_0
+1
View File
@@ -75,6 +75,7 @@ spec:
name: ak-outpost-wordpress-gate
port:
number: 9000
# anchor: gated-paths
# Covers admin-ajax.php too. That is only safe because the gift
# registry plugin -- the sole thing on this site that ever emitted
# an ajaxurl -- is being dropped in the migration. Verified against
@@ -6,6 +6,7 @@ metadata:
spec:
endpointSelector: {}
ingress:
# anchor: paperless-admit
- fromEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": paperless
@@ -25,15 +26,18 @@ spec:
# because both are load-bearing — CNPG reaches the postgres cluster
# from `database`, and the blackbox probe of
# http://paperless.paperless.svc.cluster.local:80/accounts/login/
# (kubernetes/apps/monitoring-rules/probes-blackbox.yaml:250) runs
# from `monitoring`.
# (kubernetes/apps/monitoring-rules/probes-blackbox.yaml#paperless-app-health)
# runs from `monitoring`.
# Scoping them to specific pods and ports is tracked in REN-28.
# anchor: database-admit
- fromEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": database
# anchor: monitoring-admit
- fromEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": monitoring
# anchor: host-admit
- fromEntities:
- host
- remote-node
@@ -88,12 +88,21 @@ spec:
nodeAgent:
privileged: false
# Reference the node-agent BackupPVC config (node-agent-config.yaml).
# Sets `readOnly: true` for ceph-block and ceph-filesystem source
# storage classes so the data-mover skips the CSI clone and reads
# snapshot contents directly. Saves ~2.5 h per multi-hundred-GiB
# Sets `readOnly: true` for the CephFS source storage classes
# (ceph-filesystem, ceph-filesystem-bulk) so the data-mover skips
# the CSI clone and reads snapshot contents directly. Saves ~2.5 h per multi-hundred-GiB
# CephFS Backup. Requires Velero >= 1.15 and ceph-csi >= 3.10.
extraArgs:
- --node-agent-configmap=node-agent-config
# node-agent reads node-agent-config only at startup and the chart
# does not hash it into the pod template. Bump this label whenever
# node-agent-config.yaml changes so Flux rolls the node-agent pods
# (and only them — top-level podAnnotations would also roll the
# server). Rolling kills in-flight DataUploads: merge changes here
# outside the backup window (schedules 03:15–09:15Z, immich upload
# runs ~4 h).
podLabels:
renner.uno/node-agent-config: ren-177
metrics:
# Service stays (chart-rendered) so Prometheus has a target;
# ServiceMonitor + nodeAgent PodMonitor are declared standalone under
@@ -11,6 +11,16 @@
# skip the clone entirely. Requires ceph-csi >= 3.10 (cluster runs
# 3.16.2) and Velero >= 1.15 (cluster runs 1.18.0).
#
# backupPVC is keyed by the SOURCE PVC's storage class name, so every
# CephFS class needs its own entry. ceph-filesystem-bulk (added for the
# immich / audiobookshelf bulk libraries) was missing and fell back to
# the full clone: its data-mover pods sat Pending on "unbound immediate
# PersistentVolumeClaims" for 4 and 22 min on their first nightly run
# (REN-177), growing with the data. Its backup PVC uses
# ceph-filesystem-bulk-snapshot-readonly (snapshot-readonly-
# storageclass.yaml): explicit backingSnapshot, and reclaimPolicy Delete
# instead of the source class's Retain.
#
# ceph-block (RBD) volumes intentionally use the default clone path
# (no readOnly here). The previous approach used readOnly: true with
# storageClass: ceph-block-snapshot-readonly (noload) to skip ext4
@@ -38,6 +48,10 @@ data:
"backupPVC": {
"ceph-filesystem": {
"readOnly": true
},
"ceph-filesystem-bulk": {
"readOnly": true,
"storageClass": "ceph-filesystem-bulk-snapshot-readonly"
}
}
}
@@ -37,3 +37,39 @@ mountOptions:
- noload
reclaimPolicy: Delete
allowVolumeExpansion: true
---
# Storage class used only by Velero's data-mover exposer pod for
# ceph-filesystem-bulk source PVCs (node-agent-config.yaml,
# backupPVC."ceph-filesystem-bulk".storageClass). Same cluster / fs /
# secrets as ceph-filesystem-bulk, plus:
#
# - backingSnapshot: "true" — ceph-csi provisions a shallow ReadOnlyMany
# volume that points at the CephFS snapshot instead of cloning the
# subvolume. Binds in seconds regardless of data size (REN-177: the
# clone path left the immich data mover Pending 22 min, and it grows
# with the library). Stated explicitly rather than relying on the
# ceph-csi default.
# - reclaimPolicy: Delete — the backup PVC is thrown away after each
# DataUpload; the source class's Retain would strand a PV per run.
# - no volume expansion — shallow volumes are read-only snapshots.
#
# Workload PVCs keep using ceph-filesystem-bulk; nothing else may use
# this class.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ceph-filesystem-bulk-snapshot-readonly
provisioner: rook-ceph.cephfs.csi.ceph.com
parameters:
clusterID: rook-ceph
fsName: cephfs
pool: cephfs-bulk
backingSnapshot: "true"
csi.storage.k8s.io/provisioner-secret-name: rook-csi-cephfs-provisioner
csi.storage.k8s.io/provisioner-secret-namespace: rook-ceph
csi.storage.k8s.io/controller-expand-secret-name: rook-csi-cephfs-provisioner
csi.storage.k8s.io/controller-expand-secret-namespace: rook-ceph
csi.storage.k8s.io/node-stage-secret-name: rook-csi-cephfs-node
csi.storage.k8s.io/node-stage-secret-namespace: rook-ceph
reclaimPolicy: Delete
allowVolumeExpansion: false
+62
View File
@@ -0,0 +1,62 @@
#!/bin/sh
# Offline self-test for yaml-citations.sh: each case is a small fixture tree
# that must FAIL (or, for happy-path, PASS). Run: sh scripts/ci/test-yaml-citations.sh
set -eu
HERE="$(cd "$(dirname "$0")" && pwd)"
SUT="$HERE/yaml-citations.sh"
[ -f "$SUT" ] || { echo "FAIL: $SUT not found"; exit 1; }
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT INT TERM
fails=0
# new_tree NAME — a fixture with one anchored target the cases can cite.
new_tree() {
d="$TMP/$1"; mkdir -p "$d/k/a" "$d/k/b"
printf 'kind: X\n# anchor: target-block\nspec: {}\n' > "$d/k/a/target.yaml"
echo "$d"
}
# expect CASE want(pass|fail) DIR
expect() {
if YAML_CITATIONS_FLOOR=1 sh "$SUT" "$3" > "$TMP/$1.out" 2>&1; then got=pass; else got=fail; fi
if [ "$got" = "$2" ]; then echo "ok $1 ($got)"
else echo "FAIL $1: wanted $2, got $got"; sed 's/^/ /' "$TMP/$1.out"; fails=1; fi
}
d=$(new_tree happy-path)
printf '# see target.yaml#target-block and ../a/target.yaml#target-block\nx: 1\n' > "$d/k/a/same-dir.yaml"
printf '# root-relative: k/a/target.yaml#target-block\nx: 1\n' > "$d/k/b/root.yaml"
printf 'url: "http://h/p.yaml#frag" # a # inside a value is not a comment\n' > "$d/k/b/url.yaml"
expect happy-path pass "$d"
d=$(new_tree line-number)
printf '# see ../a/target.yaml:2\nx: 1\n' > "$d/k/b/c.yaml"
expect line-number fail "$d"
d=$(new_tree line-range-yml)
printf '# see ../a/target.yml:2-3\nx: 1\n' > "$d/k/b/c.yml"
expect line-range-yml fail "$d"
d=$(new_tree missing-file)
printf '# see ../a/gone.yaml#target-block\nx: 1\n' > "$d/k/b/c.yaml"
expect missing-file fail "$d"
d=$(new_tree missing-anchor)
printf '# see ../a/target.yaml#no-such-block\nx: 1\n' > "$d/k/b/c.yaml"
expect missing-anchor fail "$d"
d=$(new_tree duplicate-anchor)
printf '# anchor: target-block\n' >> "$d/k/a/target.yaml"
expect duplicate-anchor fail "$d"
d=$(new_tree malformed-anchor)
printf '# anchor: Not_Kebab\nx: 1\n' > "$d/k/b/c.yaml"
expect malformed-anchor fail "$d"
d="$TMP/empty-discovery"; mkdir -p "$d"
if sh "$SUT" "$d" > "$TMP/empty.out" 2>&1; then echo "FAIL empty-discovery: passed with no files"; fails=1
else echo "ok empty-discovery (fail)"; fi
exit $fails
+110
View File
@@ -0,0 +1,110 @@
#!/bin/sh
# Guard the citation convention in YAML comments (REN-183, see CONTRIBUTING.md).
#
# Run: sh scripts/ci/yaml-citations.sh [repo-root]
# Needs: sh, find, awk, grep (BusyBox is fine). Offline.
# Tests: scripts/ci/test-yaml-citations.sh
#
# A comment cites another block as `path.yaml#name`, and the cited block
# carries a marker line `# anchor: name`. `path` is relative to the citing
# file's directory or to the repo root. This fails when:
#
# * a comment cites by line number (`foo.yaml:12`). Line numbers go stale on
# the first unrelated edit above them, silently; three drift fixes were
# merged before this guard existed (REN-181).
# * a `path#name` citation names a file or an anchor that does not exist.
# * an anchor is not kebab-case, or is declared twice in one file.
#
# Existence only. It does not check that the anchored block still says what the
# citing comment claims — that stays a reviewer's job, and it is why this guard
# has no false positives from ordinary edits.
set -eu
ROOT="${1:-.}"
cd "$ROOT"
# Same loose-floor reasoning as ci-manifests-test.yml: catch discovery that
# silently returns nothing, not normal churn. ~650 YAML files exist today.
FLOOR="${YAML_CITATIONS_FLOOR:-50}"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT INT TERM
# Not `find -printf` (BusyBox lacks it).
find . -path ./.git -prune -o -type f \( -name '*.yaml' -o -name '*.yml' \) -print \
| sed 's|^\./||' | sort > "$TMP/files"
count=$(grep -c . "$TMP/files" || true)
if [ "$count" -lt "$FLOOR" ]; then
echo "FAIL: found only $count YAML files; floor is $FLOOR. Discovery is broken."
exit 1
fi
# One pass over every file. A YAML comment starts at a `#` that begins the line
# or follows whitespace, so a `#` inside a URL or a quoted value is not one.
# Emits tab-separated records:
# L file line text a line-number citation
# C file line path name a path#name citation
# A file line name an anchor declaration
# B file line text a malformed anchor declaration
while IFS= read -r f; do
awk -v f="$f" '
{
if (!match($0, /(^|[ \t])#/)) next
c = substr($0, RSTART)
if (c ~ /^[ \t]*# anchor:/) {
if (c ~ /^[ \t]*# anchor: [a-z0-9]+(-[a-z0-9]+)*[ \t]*$/) {
n = c; sub(/^[ \t]*# anchor: /, "", n); sub(/[ \t]*$/, "", n)
print "A\t" f "\t" NR "\t" n
} else {
print "B\t" f "\t" NR "\t" c
}
next
}
if (c ~ /\.ya?ml:[0-9]/) print "L\t" f "\t" NR "\t" c
while (match(c, /[A-Za-z0-9_.\/-]+\.ya?ml#[A-Za-z0-9_-]+/)) {
m = substr(c, RSTART, RLENGTH)
p = m; sub(/#.*/, "", p)
n = m; sub(/.*#/, "", n)
print "C\t" f "\t" NR "\t" p "\t" n
c = substr(c, RSTART + RLENGTH)
}
}' "$f"
done < "$TMP/files" > "$TMP/records"
fail=0
while IFS="$(printf '\t')" read -r kind f line a b; do
case "$kind" in
L)
echo "FAIL $f:$line cites by line number; use path.yaml#anchor instead"
echo " $a"
fail=1 ;;
B)
echo "FAIL $f:$line malformed anchor; want '# anchor: kebab-case-name'"
fail=1 ;;
C)
dir=$(dirname "$f")
if [ -f "$dir/$a" ]; then target="$dir/$a"
elif [ -f "$a" ]; then target="$a"
else
echo "FAIL $f:$line cites $a#$b, but no such file (tried $dir/$a and ./$a)"
fail=1; continue
fi
if ! grep -qE "^[[:space:]]*# anchor: $b[[:space:]]*\$" "$target"; then
echo "FAIL $f:$line cites $a#$b, but $target has no '# anchor: $b'"
fail=1
fi ;;
esac
done < "$TMP/records"
# Duplicate anchors in one file make a citation ambiguous.
awk -F '\t' '$1 == "A" { k = $2 "\t" $4; if (k in seen) print $2 ":" $3 " duplicate anchor " $4 " (first at line " seen[k] ")"; else seen[k] = $3 }' \
"$TMP/records" > "$TMP/dups"
if [ -s "$TMP/dups" ]; then
sed 's/^/FAIL /' "$TMP/dups"
fail=1
fi
anchors=$(grep -c '^A' "$TMP/records" || true)
cites=$(grep -c '^C' "$TMP/records" || true)
[ "$fail" -eq 0 ] && echo "ok $count YAML files, $anchors anchors, $cites path#anchor citations, 0 line-number citations"
exit $fail