fix(operator): lazy-load storage gate#7
Conversation
Review notesThe change does what it intends: Four findings, most severe first:
Checked and fine: Verdict: merge after the one-line timeout fix in (1) and the comment updates in (3); (2) is intentional per the new test but deserves a deliberate decision rather than riding in silently. |
* fix(operator): bound lazy storage-gate dial by step timeout Addresses review findings on #7's lazy storage-gate change (#7 (comment)): - lazyStorageGate's closure now wraps ctx in context.WithTimeout(timeout) before calling BuildStorageGate, so the unbounded TrueNAS dial+auth (truenas.New has no internal deadline) shares the step's timeout budget with WaitDetached instead of only bounding the wait. Guarded on timeout > 0 so a zero/unset StorageTimeout degrades to "unbounded, ctx-only" rather than an instantly-expired context, matching how other steps (e.g. waitPowerOff) treat <=0 as "no override". - Reworded three comments left over from the eager storage-gate lifecycle (Config's env-at-build-time doc, Backends.Close's TrueNAS-websocket mention, and the reconciler's Close comment) to describe the current lazy dial/close-inside-the-gate-call behavior. - Added operate.TrueNASConfigured(), deduplicating the three copies of the TrueNAS env-presence check (lazyStorageGate, BuildStorageGate, and the CLI's drain-shutdown plan display). lazyStorageGate and BuildStorageGate still return a nil gate when unconfigured; only the presence check moved. The drain-path eager-identity-validation question raised in the same review is intentionally not addressed here, pending a design decision. * fix(operator): default storage-gate step timeout to 5 minutes Review follow-ups on #8: - lazyStorageGate now defaults timeout<=0 to 5 minutes (mirroring waitPowerOff) and always bounds ctx with context.WithTimeout, instead of guarding on timeout>0. The previous comment mis-cited waitPowerOff as treating <=0 as "no override" (it defaults to 5m), and leaving ctx unbounded for <=0 was incoherent anyway: iscsi.Gate.WaitClear applies WithTimeout unconditionally, so timeout=0 (reachable via the unvalidated --storage-timeout flag) meant "unbounded dial, instantly-expired wait". Now dial + wait share one coherent budget. - drop the dead buildStorageGate CLI wrapper from cmd/nightwatch/drainshutdown.go (nothing calls it since the run path moved to operate.RealBuilder) and its unused lifecycle import; its no-creds test moves to the operate package, next to BuildStorageGate.
Summary
Live verification
backends for <node>: storage gate: truenas: dial wss://<storage-endpoint>/api/current ... x509: certificate has expired ... after 2026-06-29T22:18:30ZTests
go test ./...