From d9e4eaf485b9516cfffa9c8f5ddbbf1a99365026 Mon Sep 17 00:00:00 2001 From: Paschalis Tsilias Date: Fri, 21 Jan 2022 16:26:30 +0200 Subject: [PATCH] Skip non-ready entries when listing instances (#1289) * Skip non-ready instances in LoadInstances() Signed-off-by: Paschalis Tsilias * Add changelog entry Co-authored-by: Robert Fratto --- CHANGELOG.md | 4 ++++ pkg/metrics/instance/manager.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08cf5b2c52cd..9c78cb634835 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ - [ENHANCEMENT] Go 1.17 is now used for all builds of the Agent. (@tpaschalis) +- [BUGFIX] Fixed issue where Grafana Agent may panic if there is a very large + WAL loading while old WALs are being deleted or the `/agent/api/v1/targets` + endpoint is called. (@tpaschalis) + # v0.22.0 (2022-01-13) This release has deprecations. Please read [DEPRECATION] entries and consult diff --git a/pkg/metrics/instance/manager.go b/pkg/metrics/instance/manager.go index a27012e63a10..a622d073b0f2 100644 --- a/pkg/metrics/instance/manager.go +++ b/pkg/metrics/instance/manager.go @@ -149,6 +149,9 @@ func (m *BasicManager) ListInstances() map[string]ManagedInstance { res := make(map[string]ManagedInstance, len(m.processes)) for name, process := range m.processes { + if process == nil { + continue + } res[name] = process.inst } return res