From 9970e4e7e48b4277301bdbc54d21bc50f45a1aa1 Mon Sep 17 00:00:00 2001 From: Augustin Husson Date: Wed, 5 Sep 2018 15:12:07 +0200 Subject: [PATCH] unregister source when the target is empty Signed-off-by: Augustin Husson --- discovery/manager.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/discovery/manager.go b/discovery/manager.go index bb4409fea..ab8328924 100644 --- a/discovery/manager.go +++ b/discovery/manager.go @@ -232,6 +232,11 @@ func (m *Manager) updateGroup(poolKey poolKey, tgs []*targetgroup.Group) { m.targets[poolKey] = make(map[string]*targetgroup.Group) } m.targets[poolKey][tg.Source] = tg + + // Clear the key in the case where the targets is empty. + if tg.Targets == nil || len(tg.Targets) <= 0 { + delete(m.targets[poolKey], tg.Source) + } } } }