From af6dc9c9639f7b1aed42e82b7560ed1dc7cd0f58 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin <valyala@victoriametrics.com> Date: Thu, 26 Oct 2023 00:06:26 +0200 Subject: [PATCH] lib/promscrape: properly track the number of updated service discovery routines inside Config.mustRestart() This is a follow-up for d5a599badce3ff84c3ef236e1e8c3fb38514f272 --- lib/promscrape/config.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/promscrape/config.go b/lib/promscrape/config.go index ed0e8c40c0..84ddf47d2a 100644 --- a/lib/promscrape/config.go +++ b/lib/promscrape/config.go @@ -187,12 +187,13 @@ func (cfg *Config) mustRestart(prevCfg *Config) bool { } jobNames := cfg.getJobNames() tsmGlobal.registerJobNames(jobNames) - hasChanges := started > 0 || stopped > 0 || restarted > 0 - if hasChanges { - logger.Infof("updated %d service discovery routines in %.3f seconds, started=%d, stopped=%d, restarted=%d", - len(cfg.ScrapeConfigs), time.Since(startTime).Seconds(), started, stopped, restarted) + updated := started + stopped + restarted + if updated == 0 { + return false } - return hasChanges + logger.Infof("updated %d service discovery routines in %.3f seconds, started=%d, stopped=%d, restarted=%d", + updated, time.Since(startTime).Seconds(), started, stopped, restarted) + return true } func areEqualGlobalConfigs(a, b *GlobalConfig) bool {