Replica mirror (the local Snapshot) #10
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lab/authz-bridge!10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/replica-mirror"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #4
Implements the replica mirror: every replica watches the managed Registry Secret and the referenced per-App Secrets and maintains its local in-memory Snapshot — rebuilt whole and atomically swapped on any change, never leader-gated.
What
internal/snapshot— the new package:Build(pure, Seam 2 per spec #1): Registry + watched-Secret bytes → an immutable Snapshot; the hostname index and the App set are built together in one pass and can never disagree; input-isolated (deep-copied). Per-App bytes-present is derived from the local watch (absent Secret or missing key → false → 5xx, the App is kept, ADR-0006); the leader'ssecretReadyflag is zeroed in the copy — the localApp.SecretReadyis the served 5xx flag.Coalesce: a burst of events leaves at most one signal queued (buffered-1, non-blocking signal) — at most one in-flight rebuild plus one follow-up.Mirror: subscribes to the cluster-wide Secret informer (registry + referenced-Secret events, per-replica watched set re-derived on Registry change), bootstraps from the current cluster state (absent Registry Secret is valid; absent referenced Secret → 5xx — no leader round-trip), and runs the coalesced rebuild loop with a whole-block atomic pointer swap.Current()is a singleatomic.Pointerload (lock-free).NeedLeaderElection() == falseputs it in the manager's "others" runnable group — without it a plainRunnableis classified into the leader-election group and only the leader would mirror (caught in review).cmd/main.go— the Mirror registered as a manager runnable (not leader-gated).Acceptance criteria
Consistentlywhole-state invariant while the Registry churns.atomic.Pointerload; the write mutex is never held on the read path (plusgo test -race).mgr.Add(mirror)).Judgement calls
parseRegistrykeeps last-good state on a malformed Registry document (the served Snapshot is never blanked by a bad write) — not in the ACs, harmless, matches the ADR last-good spirit.Rebuilds()counter: observable behaviour the AC testability needs (burst spec).Notes
secrets get;list;watch) onmirror.godeclares the mirror's own read need (previously covered only transitively by the leader's marker);make manifests—config/rbac/role.yamlunchanged (verb union identical).