Skip to content

Commit

Permalink
daemon, ipcache: Plumb root context to IP identity watcher
Browse files Browse the repository at this point in the history
In the case that the Agent goes down, it can properly signal to the
ipcache package to tear down the IP identity watcher goroutine.

This doesn't resolve any bugs that I'm aware of and just found it via
code inspection.

Signed-off-by: Chris Tarazi <chris@isovalent.com>
  • Loading branch information
christarazi authored and joamaki committed Dec 19, 2022
1 parent 3961355 commit ca52560
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion daemon/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ func newDaemon(ctx context.Context, cleaner *daemonCleanup,
// Start watcher for endpoint IP --> identity mappings in key-value store.
// this needs to be done *after* init() for the daemon in that function,
// we populate the IPCache with the host's IP(s).
d.ipcache.InitIPIdentityWatcher()
d.ipcache.InitIPIdentityWatcher(d.ctx)
identitymanager.Subscribe(d.policy)

// Start listening to changed devices if requested.
Expand Down
4 changes: 2 additions & 2 deletions pkg/ipcache/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ var (

// InitIPIdentityWatcher initializes the watcher for ip-identity mapping events
// in the key-value store.
func (ipc *IPCache) InitIPIdentityWatcher() {
func (ipc *IPCache) InitIPIdentityWatcher(ctx context.Context) {
setupIPIdentityWatcher.Do(func() {
go func() {
log.Info("Starting IP identity watcher")
watcher = NewIPIdentityWatcher(ipc, kvstore.Client())
close(initialized)
watcher.Watch(context.TODO())
watcher.Watch(ctx)
}()
})
}
Expand Down

0 comments on commit ca52560

Please sign in to comment.