feat(site): persist site configuration in ConfigMaps #514
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!514
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/site-config-persistence"
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?
What
Make site registration survive daemon restarts by persisting site state in Kubernetes ConfigMaps:
ConfigMapRepository(internal/kubernetes/site_repository.go) implementssite.SiteRepository, storing each site as a JSON-encoded ConfigMap namedsite-<name>with athwap.pagesd/site=truelabel for list selection.Create/Get/List/Update/Deletemirror the in-memory repository semantics (ErrExists/ErrNotFound) using the kubernetes clientset.main.gowireskubernetes.NewSiteRepository(kubeClient, namespace)in place of the memory repository.Why
Phase 7 task #96 — replaces the ephemeral in-memory site store so registrations persist across restarts.
Testing
go build ./...go vet ./...go test -race ./...— 8 new fake-clientset tests (create/get roundtrip, duplicate, missing resources, list, update, delete); full suite passesgofmt -l ./cmd ./internal ./pkgcleangolangci-lint run— 0 issuesBreaking Changes
None.
Notes
MemoryRepositoryremains for tests;mainnow uses the ConfigMap-backed repository.Closes #94
Closes #95
Closes #96
Review Summary
Verified locally on the PR head (
cc09079):go build,go vet,gofmt,golangci-lint runall clean; all 8 new ConfigMap-repository tests plus the full suite pass with-race.Solid implementation.
ConfigMapRepositoryfaithfully mirrors theSiteRepositorysemantics (ErrExists/ErrNotFound), stores each site as JSON undersite-<name>with athwap.pagesd/site=truelabel for list selection, andUpdatecorrectly reuses the fetched object'sResourceVersion. The name prefix (site-) can't collide with the per-site nginx ConfigMaps (named<name>), and site-name length limits keep ConfigMap names within DNS-1123 bounds.main.gowiring is a one-line swap, leaving the memory repo for tests. Fake-clientset test coverage is good (roundtrip, duplicate, missing, list, update, delete).No blocking issues.
Non-blocking observations:
Create's existence check isGet-then-Create(non-atomic) — concurrent duplicate registration could surface as a rawAlreadyExistsAPI error instead ofErrExistsin the race window. Fine for the single-instance daemon; worth noting if the API ever scales out.Createproceeds past a non-notfoundGeterror (e.g. transient RBAC/API error) rather than aborting — it would then surface the error onCreate. Harmless today, slightly surprising error path.Approving.