docs: record the CNPG leader-election fix and its real cause

§9.2 now states the cause as shared-NVMe contention from CI build I/O (etcd
wal_fsync 158 >8.192s / 2,518 >2.048s of 14.81M, worst stall 10.39s, every
stall hour carrying CI I/O) and cites d5d1d28 for the widened window plus the
operator's move into Flux. The static-pod controller-manager/scheduler
restarts and the one CI-unexplained stall hour are called out as open.
Refreshes the live Flux revision, the Kustomization count and the operator pod.
This commit is contained in:
Lance Walters 2026-10-26 15:41:35 -04:00
commit 3cfb89fa2c

View file

@ -315,7 +315,7 @@ A single `ReferenceGrant` exists (`gateway-system/forgejo`) for the cross-namesp
| # | Namespace | Pod | Node | IP | Purpose | Exposure |
|---|---|---|---|---|---|---|
| 1 | cnpg-system | `cnpg-controller-manager-955555df8-d5m8j` | siriussec | 10.244.0.121 | CloudNativePG operator (1.30.0) | internal |
| 1 | cnpg-system | `cnpg-controller-manager-78484bd58d-m6rtk` | siriussec | 10.244.0.183 | CloudNativePG operator (1.30.0) | internal |
| 2 | flux-system | `helm-controller-5788b55f98-zzgmw` | siriussec | 10.244.0.210 | Flux HelmRelease reconciler | internal |
| 3 | flux-system | `kustomize-controller-645cdc4b67-r2gl6` | siriussec | 10.244.0.30 | Flux kustomize reconciler (applies all YAML) | internal |
| 4 | flux-system | `notification-controller-7cd6d4994b-drh8x` | siriussec | 10.244.0.125 | Flux alerts/webhooks | internal |
@ -424,13 +424,15 @@ kubectl -n flux-system annotate kustomization apps \
reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
```
**Live Flux state:** GitRepository `flux-system` → `https://forgejo.siriusdevops.com/sirius/homek8s`, Ready, artifact `master@sha1:bd5057c`; all four Kustomizations (`flux-system`, `gateway-api-crds`, `infrastructure`, `apps`) `Ready=True` on the same revision. Cilium is managed as a HelmRelease **by Flux** — never `helm upgrade` it by hand.
**Live Flux state:** GitRepository `flux-system` → `https://forgejo.siriusdevops.com/sirius/homek8s`, Ready, artifact `master@sha1:d5d1d28`; all five Kustomizations (`flux-system`, `gateway-api-crds`, `databases`, `infrastructure`, `apps`) `Ready=True` on the same revision. Cilium is managed as a HelmRelease **by Flux** — never `helm upgrade` it by hand.
Repository layout:
```
clusters/homek8s/ flux-system GitRepository + 4 Kustomizations
infrastructure/home/ entrypoint for infra (cilium, gateway, storage, databases)
clusters/homek8s/ flux-system GitRepository + 5 Kustomizations
infrastructure/home/ entrypoint for infra (cilium, gateway, storage)
infrastructure/databases/base/ CloudNativePG 1.30.0 operator, vendored + patched
(own Flux Kustomization `databases`, prune: false — CRDs)
apps/home/ forgejo, siriusdevops, piedmont, sirius-growth
monitoring/controllers/home/ (present in repo, NOT deployed — no monitoring namespace exists)
```
@ -469,7 +471,12 @@ Host disks *(live)*: siriussec `/` 214 G, 141 G used (**70%**, 62 G free); rpi `
### 9.2 Smaller, still real
- `cilium-operator` election window was widened (`--leader-election-lease-duration=60s`, `renew-deadline=45s`, `resource-lock-timeout=20s`) because etcd `wal_fsync` stalls on the shared NVMe make it exit. The operator restarted 25 min before this reading; the static-pod controller-manager and scheduler show ~227–230 restarts. That is an **etcd I/O** problem, not a Cilium one.
- **Leader-election fatals are an I/O-contention problem, and the two GitOps operators are now fixed for it.** The root cause is *shared-NVMe contention from CI build I/O*, not a slow or failing disk: etcd `wal_fsync` on `/dev/nvme0n1p3` (the same device as the dind data-root and `forgejo-data`) records **158 samples >8.192 s and 2,518 >2.048 s out of 14,813,192**, while 99.6 % land ≤32 ms — i.e. tail stalls of 5–10.4 s, worst **10.39 s at `2026-10-23T02:48:44Z`**. Every one of the 8 hours containing a ≥2 s stall had CI build I/O running (7 of 8 the amd64 dind runner); light deploy-only hours with the runner present produced none. A single stall exceeds client-go's 5 s lease-renewal HTTP timeout, controller-runtime reports `leader election lost`, and the manager fatals by design (`exit 1`).
- `cnpg-controller-manager` — **223 restarts / 45 d, fixed in `d5d1d28`** with `--leader-lease-duration=60 --leader-renew-deadline=45` (integer **seconds**; CNPG has no `resource-lock-timeout` flag, unlike Cilium). The same commit vendors the pinned 1.30.0 operator manifest into `infrastructure/databases/base/` and gives it its own Flux Kustomization `databases` (`prune: false` — the bundle carries the 11 CNPG CRDs, and pruning those would delete both clusters), so the args are declared state instead of a hand patch. The patch also preserves the pre-existing live deltas upstream does not ship (overlay API env `10.10.0.2:6443`, 500m/512Mi limits, 3 min startup probe). Live lease `cnpg-system/db9c8771.cnpg.io` reports `leaseDurationSeconds: 60`.
- `cilium-operator` — widened earlier in `bd5057c` (`--leader-election-lease-duration=60s`, `renew-deadline=45s`, `resource-lock-timeout=20s`) in `infrastructure/networking/cilium/values.yaml`.
- `kube-controller-manager` (~227) and `kube-scheduler` (~230) restarts are the *same stall event*, but they are kubeadm static pods, not GitOps: they were **not** changed and need their own `--leader-elect` tuning pass.
- Honest gap: one stall hour (`2026-10-24 22`, 18 events, worst 5.95 s) had **no** amd64 runner job and began the same minute a Pi-side `onionwire` job started. Unexplained but observed — do not claim dind-on-siriussec is the sole source.
- 60 s is a tourniquet, comfortably above the 10.4 s worst case; widening further fixes nothing. The real remedies — cgroup-v2 `io.max`/`io.weight` on the dind pod, moving the dind data-root or `forgejo-data` off the etcd device, capping dind growth — are a separate change with cluster-wide blast radius.
- Pi ufw allows `22/tcp` from anywhere, plus `10.10.0.0/24`, `10.244.0.0/16` and `51820/udp`; the WG forward rules between `wg0` and `wg-remote` are in place. The Linode hub also needs its own `FORWARD` accepts or spoke traffic dies past the hub.
- Two stale WireGuard peers exist: mesh `10.10.0.4` (6 days, Tailscale endpoint) and Linode-hub `10.20.0.4` (no handshake). Harmless but misleading in `wg show`.
- The Pi runs **Tailscale** (`tailscale0`, `100.71.235.119`) alongside WireGuard. Do not plan recovery around Tailscale-only paths; treat WireGuard/LAN as the primary.
@ -533,4 +540,13 @@ All times 2026-10-26 UTC. `kubeconfig` on the Legion admin laptop → `https://1
| 31 | siriussec: `uname -r`, `pacman -Q linux-lts` | `6.18.50-2-lts`; `7.2.3-arch1-3` also installed |
| 32 | linode (via Pi hop): `hostname`, `ip -br addr`, `wg show wg0` | `dummy-k8s 10.10.0.5/32`, `wg0 10.20.0.1/24`, 4 peers, uptime 3 d 17 h |
**CNPG leader-election fix, re-verified 2026-10-26 19:37–19:45 UTC (commit `d5d1d28`):**
| # | Command | Key result |
|---|---|---|
| 33 | `kubectl -n cnpg-system get deploy cnpg-controller-manager` (`--show-managed-fields`) | args `--leader-lease-duration=60`, `--leader-renew-deadline=45`; preserved `KUBERNETES_SERVICE_HOST=10.10.0.2`, 500m/512Mi, startupProbe 36; managedFields owner `kustomize-controller` `Apply` → Flux owns it |
| 34 | `kubectl -n cnpg-system get lease db9c8771.cnpg.io -o jsonpath` | `leaseDurationSeconds: 60` (was 15), holder = new pod `78484bd58d-m6rtk`, `renewTime` advancing; `leader election lost` count in the new pod's log: **0**; restarts 223 → **0** on the new ReplicaSet |
| 35 | `kubectl -n flux-system get kustomization`; `kubectl get cluster -A` | new `databases` Kustomization `Ready=True` at `master@sha1:d5d1d28`; all 5 Ready; `forgejo/pg` + `sirius-growth/portal` both `Ready=True`; `forgejo.siriusdevops.com` **200** public and `Host:` curl to `10.10.0.2:8080` **200** |
| 36 | siriussec: `curl :2381/metrics` (etcd) | `wal_fsync` 158 >8.192 s / 2,518 >2.048 s of 14,813,192; `backend_commit` 187 >8.192 s of 6,652,027; 99.6 %/99.7 % ≤32 ms — matches the stated stall profile, so this is spiky contention, not a failing disk |
**Not verified, deliberately:** Cloudflare DNS records, Forgejo's `app.ini`, any secret material, and the SG-VPS/phone spoke routing beyond what the Linode's `wg show` reports.