From be88c2c85b8b9caa4e5f6d2508daa0377f7f9e80 Mon Sep 17 00:00:00 2001 From: Zakhar Bessarab Date: Fri, 22 Sep 2023 15:01:33 +0400 Subject: [PATCH] lib/promscrape/discovery/kubernetes: supress context.Cancelled error in logs (#5048) lib/promscrape/discovery/kubernetes: supress context.Cancelled error in logs It is possible that context.Cancelled will appear after k8s watcher was closed due to reload(see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4850). Logging an error misinforms user and looks like vmagent discovery will stop working even though this does not affect discovery. Signed-off-by: Zakhar Bessarab --- docs/CHANGELOG.md | 1 + lib/promscrape/discovery/kubernetes/api_watcher.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d5330880b..3827fdf23 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,6 +13,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components ## v1.93.x long-time support release (LTS) * BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): properly copy `appliedRetention.txt` files inside `<-storageDataPath>/{data}` folders during [incremental backups](https://docs.victoriametrics.com/vmbackup.html#incremental-backups). Previously the new `appliedRetention.txt` could be skipped during incremental backups, which could lead to increased load on storage after restoring from backup. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5005). +* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): suppress `context canceled` error messages in logs when `vmagent` is reloading service discovery config. This error could appear starting from [v1.93.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.5). See [this PR](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5048). ## [v1.93.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.5) diff --git a/lib/promscrape/discovery/kubernetes/api_watcher.go b/lib/promscrape/discovery/kubernetes/api_watcher.go index 3d4f0c806..b677bd241 100644 --- a/lib/promscrape/discovery/kubernetes/api_watcher.go +++ b/lib/promscrape/discovery/kubernetes/api_watcher.go @@ -771,7 +771,7 @@ func (uw *urlWatcher) watchForUpdates() { err = uw.readObjectUpdateStream(resp.Body) _ = resp.Body.Close() if err != nil { - if !errors.Is(err, io.EOF) { + if !(errors.Is(err, io.EOF) || errors.Is(err, context.Canceled)) { logger.Errorf("error when reading WatchEvent stream from %q: %s", requestURL, err) uw.resourceVersion = "" }