From 60f2893152d947b15a23138dd2518100560ec41a Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Wed, 7 Jul 2021 14:34:12 -0500 Subject: [PATCH] Add usageCache logging --- api.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api.go b/api.go index 3361780fd..cc9633d86 100644 --- a/api.go +++ b/api.go @@ -915,9 +915,8 @@ type usageCache struct { } var usageCacheMinDuration = 5 * time.Second // If usage takes less than this duration to calculate, don't use the cache. -var usageCacheMinInterval = time.Hour // Refresh interval is forced to be >= this duration. -var usageCacheInitialInterval = time.Hour // Refresh interval starts with this duration. -var usageCacheDebugSleep = 10 * time.Second +var usageCacheMinInterval = time.Hour // Refresh interval is forced to be >= this duration. +var usageCacheInitialInterval = time.Hour // Refresh interval starts with this duration. // NodeUsage represents all usage measurements for one node. type NodeUsage struct { @@ -979,7 +978,6 @@ func (api *API) Usage(ctx context.Context, remote bool) (map[string]NodeUsage, e if !remote { api.requestUsageOfNodes() } - time.Sleep(usageCacheDebugSleep) return api.usageCache.data, nil } @@ -1083,10 +1081,12 @@ func (api *API) RefreshUsageCache(dutyCycle float64) { lastCalcDuration: 0, waitMultiplier: multiplier, } + api.server.logger.Infof("monitoring resource usage with duty cycle %v%%\n", dutyCycle) for { start := time.Now() api.calculateUsage() api.setRefreshInterval(time.Since(start)) + api.server.logger.Infof("updated resource usage cache at %v, took %v, next update in %v\n", api.usageCache.lastUpdated.Format(time.RFC3339), api.usageCache.lastCalcDuration, api.usageCache.refreshInterval) select { case <-trigger: continue