Browse Source

remove group if the target is empty at adapter level

Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
pull/4575/head
Augustin Husson 6 years ago
parent
commit
97950a3fae
  1. 5
      discovery/manager.go
  2. 6
      documentation/examples/custom-sd/adapter/adapter.go

5
discovery/manager.go

@ -232,11 +232,6 @@ 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)
}
}
}
}

6
documentation/examples/custom-sd/adapter/adapter.go

@ -60,6 +60,12 @@ func (a *Adapter) generateTargetGroups(allTargetGroups map[string][]*targetgroup
tempGroups := make(map[string]*customSD)
for k, sdTargetGroups := range allTargetGroups {
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)
newLabels := make(map[string]string)

Loading…
Cancel
Save