diff --git a/broker/client.go b/broker/client.go index 6518419ca..81064c0b8 100644 --- a/broker/client.go +++ b/broker/client.go @@ -286,6 +286,7 @@ func ConnectToOrigin(ctx context.Context, brokerUrl, prefix, originName string) // Wait for the origin to callback to the cache's return endpoint; that HTTP handler // will write to the channel we originally posted. tck := time.NewTicker(20 * time.Second) + defer tck.Stop() log.Debugf("Cache waiting for up to 20 seconds for the origin %s to callback", originName) select { case <-ctx.Done(): diff --git a/cmd/progress_bars.go b/cmd/progress_bars.go index 2e485a5f9..4aa8c4fdd 100644 --- a/cmd/progress_bars.go +++ b/cmd/progress_bars.go @@ -90,6 +90,7 @@ func (pb *progressBars) launchDisplay(ctx context.Context) { tickDuration := 200 * time.Millisecond ticker := time.NewTicker(tickDuration) + defer ticker.Stop() pbMap := make(map[string]*progressBar) for { select { diff --git a/director/advertise.go b/director/advertise.go index 804eb8a83..2ccbfbf00 100644 --- a/director/advertise.go +++ b/director/advertise.go @@ -294,6 +294,7 @@ func AdvertiseOSDF(ctx context.Context) error { func PeriodicCacheReload(ctx context.Context) { ticker := time.NewTicker(param.Federation_TopologyReloadInterval.GetDuration()) + defer ticker.Stop() for { select { case <-ticker.C: diff --git a/director/maxmind.go b/director/maxmind.go index 688bbca74..0b985fcd9 100644 --- a/director/maxmind.go +++ b/director/maxmind.go @@ -123,6 +123,7 @@ func periodicMaxMindReload(ctx context.Context) { // Update once every other day ticker := time.NewTicker(48 * time.Hour) + defer ticker.Stop() for { select { case <-ticker.C: diff --git a/launcher_utils/advertise.go b/launcher_utils/advertise.go index aa5400472..6daddad55 100644 --- a/launcher_utils/advertise.go +++ b/launcher_utils/advertise.go @@ -68,6 +68,7 @@ func LaunchPeriodicAdvertise(ctx context.Context, egrp *errgroup.Group, servers doAdvertise(ctx, servers) ticker := time.NewTicker(1 * time.Minute) + defer ticker.Stop() egrp.Go(func() error { for { diff --git a/launcher_utils/register_namespace.go b/launcher_utils/register_namespace.go index 8dd86334e..3159dac3b 100644 --- a/launcher_utils/register_namespace.go +++ b/launcher_utils/register_namespace.go @@ -295,6 +295,7 @@ func RegisterNamespaceWithRetry(ctx context.Context, egrp *errgroup.Group, prefi egrp.Go(func() error { ticker := time.NewTicker(retryInterval) + defer ticker.Stop() for { select { case <-ticker.C: diff --git a/local_cache/local_cache.go b/local_cache/local_cache.go index 40fb7af43..71df19cdf 100644 --- a/local_cache/local_cache.go +++ b/local_cache/local_cache.go @@ -365,6 +365,7 @@ func (sc *LocalCache) runMux() error { activeJobs := make(map[string]*activeDownload) jobPath := make(map[string]string) ticker := time.NewTicker(100 * time.Millisecond) + defer ticker.Stop() clientClosed := false for { lenResults := len(tmpResults) @@ -761,6 +762,7 @@ func (sc *LocalCache) updateConfig() error { // Periodically update the cache configuration from the registry func (sc *LocalCache) periodicUpdateConfig() error { ticker := time.NewTicker(time.Minute) + defer ticker.Stop() for { select { case <-sc.ctx.Done(): diff --git a/server_utils/monitor.go b/server_utils/monitor.go index 9fa35ffda..9c305d09d 100644 --- a/server_utils/monitor.go +++ b/server_utils/monitor.go @@ -59,6 +59,7 @@ func LaunchPeriodicDirectorTimeout(ctx context.Context, egrp *errgroup.Group, nC return } directorTimeoutTicker := time.NewTicker(directorTimeoutDuration) + defer directorTimeoutTicker.Stop() egrp.Go(func() error { for { diff --git a/server_utils/server_utils.go b/server_utils/server_utils.go index 15fa6b58f..08fe2ceec 100644 --- a/server_utils/server_utils.go +++ b/server_utils/server_utils.go @@ -215,6 +215,7 @@ func LaunchWatcherMaintenance(ctx context.Context, dirPaths []string, descriptio } cases := make([]reflect.SelectCase, select_count) ticker := time.NewTicker(sleepTime) + defer ticker.Stop() cases[0].Dir = reflect.SelectRecv cases[0].Chan = reflect.ValueOf(ticker.C) cases[1].Dir = reflect.SelectRecv diff --git a/utils/ca_utils.go b/utils/ca_utils.go index f86acf1ee..b1849518d 100644 --- a/utils/ca_utils.go +++ b/utils/ca_utils.go @@ -97,6 +97,7 @@ func LaunchPeriodicWriteCABundle(ctx context.Context, egrpKey string, filename s } egrp.Go(func() error { ticker := time.NewTicker(sleepTime) + defer ticker.Stop() for { select { case <-ticker.C: diff --git a/web_ui/authentication.go b/web_ui/authentication.go index 9171269f2..9b2a5d5b8 100644 --- a/web_ui/authentication.go +++ b/web_ui/authentication.go @@ -85,6 +85,7 @@ const ( // Periodically re-read the htpasswd file used for password-based authentication func periodicAuthDBReload(ctx context.Context) error { ticker := time.NewTicker(30 * time.Second) + defer ticker.Stop() for { select { case <-ticker.C: diff --git a/web_ui/prometheus.go b/web_ui/prometheus.go index 6341a1020..337835ad6 100644 --- a/web_ui/prometheus.go +++ b/web_ui/prometheus.go @@ -673,6 +673,7 @@ func ConfigureEmbeddedPrometheus(ctx context.Context, engine *gin.Engine) error return errors.New("Refresh interval is non-positive value. Stop reloading.") } ticker := time.NewTicker(refreshInterval) + defer ticker.Stop() for { select { case <-cancel: