remove group if the target is empty at adapter level
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
parent
9970e4e7e4
commit
97950a3fae
|
@ -232,11 +232,6 @@ func (m *Manager) updateGroup(poolKey poolKey, tgs []*targetgroup.Group) {
|
||||||
m.targets[poolKey] = make(map[string]*targetgroup.Group)
|
m.targets[poolKey] = make(map[string]*targetgroup.Group)
|
||||||
}
|
}
|
||||||
m.targets[poolKey][tg.Source] = tg
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,12 @@ func (a *Adapter) generateTargetGroups(allTargetGroups map[string][]*targetgroup
|
||||||
tempGroups := make(map[string]*customSD)
|
tempGroups := make(map[string]*customSD)
|
||||||
for k, sdTargetGroups := range allTargetGroups {
|
for k, sdTargetGroups := range allTargetGroups {
|
||||||
for i, group := range sdTargetGroups {
|
for i, group := range sdTargetGroups {
|
||||||
|
|
||||||
|
// There is no target, so no need to keep it
|
||||||
|
if len(group.Targets) <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
newTargets := make([]string, 0)
|
newTargets := make([]string, 0)
|
||||||
newLabels := make(map[string]string)
|
newLabels := make(map[string]string)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue