Skip to content

Commit

Permalink
daemon: put KVWatcher channel inside a for loop
Browse files Browse the repository at this point in the history
By putting the channel inside a for loop we make sure the policy trigger
always happen for all changes in LastUUID.

Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm authored and tgraf committed Mar 16, 2017
1 parent cc74306 commit a26b8c2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions daemon/kvstore_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ import (
func (d *Daemon) EnableKVStoreWatcher(maxSeconds time.Duration) {
ch := d.kvClient.GetWatcher(common.LastFreeLabelIDKeyPath, maxSeconds)
go func() {
select {
case updates := <-ch:
d.triggerPolicyUpdates(updates)
for {
select {
case updates, update_ok := <-ch:
if !update_ok {
log.Debugf("Watcher for %s closed, reacquiring it", common.LastFreeLabelIDKeyPath)
ch = d.kvClient.GetWatcher(common.LastFreeLabelIDKeyPath, maxSeconds)
}
d.triggerPolicyUpdates(updates)
}
}
}()
}

0 comments on commit a26b8c2

Please sign in to comment.