carlos / platform Public

housekeeperContends: nil-safe before startHousekeeper, like held()/gate() (review nit)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev d0b727db66f73906af0cda239e3d86018024c30f parent 7d3e761
1 file changed, +7 −1
  • internal/host/housekeeper.go +7 −1
diff --git a/internal/host/housekeeper.go b/internal/host/housekeeper.go
index e43461f5e..cbd4502fb 100644
--- a/internal/host/housekeeper.go
+++ b/internal/host/housekeeper.go
@@ -384,7 +384,13 @@ func housekeeperGate() (context.Context, bool) { return theHousekeeper.Load().ga
// grandfathered with the bucket env is agent-run and gated, but mode
// "never" — its disk holds a customer's certs, never this deployment's to
// publish.
-func housekeeperContends() bool { return theHousekeeper.Load().mode != housekeeperNever }
+func housekeeperContends() bool {
+ // Nil-safe like held()/gate(): several agent loops start before
+ // startHousekeeper, and a caller from one of them should read "does not
+ // contend", not panic.
+ hk := theHousekeeper.Load()
+ return hk != nil && hk.mode != housekeeperNever
+}
// startHousekeeper arms the election for this process and returns its
// stand-down. Called once from RunAgent, before the loops whose duties it