return early for nil target groups

This commit is contained in:
Krasi Georgiev 2018-01-05 10:56:56 +00:00
parent 77bf6bece0
commit 546c29af5b
1 changed files with 10 additions and 7 deletions

View File

@ -154,14 +154,17 @@ func (m *Manager) updateGroup(poolKey poolKey, tgs []*targetgroup.Group) {
done := make(chan struct{}) done := make(chan struct{})
m.actionCh <- func(ctx context.Context) { m.actionCh <- func(ctx context.Context) {
if tgs != nil { if tgs == nil {
for _, tg := range tgs { close(done)
if tg != nil { // Some Discoverers send nil targetgroup so need to check for it to avoid panics. return
if _, ok := m.targets[poolKey]; !ok { }
m.targets[poolKey] = make(map[string]*targetgroup.Group)
} for _, tg := range tgs {
m.targets[poolKey][tg.Source] = tg if tg != nil { // Some Discoverers send nil targetgroup so need to check for it to avoid panics.
if _, ok := m.targets[poolKey]; !ok {
m.targets[poolKey] = make(map[string]*targetgroup.Group)
} }
m.targets[poolKey][tg.Source] = tg
} }
} }
close(done) close(done)