You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[KLC-2402] appStatusPolling: make Poll stoppable; wire shutdown (#57)
* [KLC-2402] appStatusPolling: make Poll stoppable; wire shutdown
Replaces the unbounded `for { Sleep; ... }` goroutine in AppStatusPolling
with a select over a `done` channel and a ticker, exposing an idempotent
`Close() error` (io.Closer). Killed a pre-existing nil-pointer panic in
TestStartStatusPolling/Valid_configuration, where the leaked goroutine
outlived the test and fired against a stub with a nil method handler.
API:
- metrics.StartStatusPolling, StartNodeMetricsPolling, and
StartMachineStatisticsPolling now return (io.Closer, error).
Shutdown:
- cmd/node/startup.go captures the three closers and passes them to
closeAllComponents, which now Closes them first — before tearing down
the components their handlers read from (NetMessenger, Store, etc.).
- Close signals stop but does not block on the goroutine, per the
ticket's requirement.
Tests:
- matics_test.go and appStatusPolling_test.go register t.Cleanup to
Close pollers, eliminating the test goroutine leak.
- Added TestAppStatusPolling_Close_IsIdempotent and
TestAppStatusPolling_Close_StopsGoroutine.
Out of scope (separate ticket): the leaky `for {}` goroutines inside
registerCPUStatistics / registerNetStatistics / registerDiskStatistics.
* fix(KLC-2402): address review feedback
- StartStatusPolling: check.IfNil(ash) for typed-nil safety
- StartMachineStatisticsPolling: add check.IfNil(notifier) guard
- Wrap NewAppStatusPolling error with %w in both Start* wrappers
- Test: fix duration multiplication typo (~63yr -> 2s)
- Test: use require.Eventually for first-tick wait; settling-window check for post-Close stability
0 commit comments