diff --git a/internal/outpost/ak/api_ws.go b/internal/outpost/ak/api_ws.go index 4b2f1f8c4f..210b7e5335 100644 --- a/internal/outpost/ak/api_ws.go +++ b/internal/outpost/ak/api_ws.go @@ -183,7 +183,19 @@ func (ac *APIController) startWSHealth() { func (ac *APIController) startIntervalUpdater() { logger := ac.logger.WithField("loop", "interval-updater") - ticker := time.NewTicker(time.Duration(ac.Outpost.RefreshIntervalS) * time.Second) + getInterval := func() time.Duration { + // Ensure timer interval is not negative or 0 + // for 0 we assume migration or unconfigured, so default to 5 minutes + if ac.Outpost.RefreshIntervalS <= 0 { + return 5 * time.Minute + } + // Clamp interval to be at least 30 seconds + if ac.Outpost.RefreshIntervalS < 30 { + return 30 * time.Second + } + return time.Duration(ac.Outpost.RefreshIntervalS) * time.Second + } + ticker := time.NewTicker(getInterval()) for ; true; <-ticker.C { logger.Debug("Running interval update") err := ac.OnRefresh() @@ -198,7 +210,7 @@ func (ac *APIController) startIntervalUpdater() { "build": constants.BUILD("tagged"), }).SetToCurrentTime() } - ticker.Reset(time.Duration(ac.Outpost.RefreshIntervalS) * time.Second) + ticker.Reset(getInterval()) } }