Skip to content

Commit

Permalink
Before starting a new watcher, reap dead ones
Browse files Browse the repository at this point in the history
Signed-off-by: John Belamaric <[email protected]>
  • Loading branch information
johnbelamaric committed Nov 20, 2023
1 parent 86a3a16 commit 5d62251
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions porch/pkg/engine/watchermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ func (r *watcherManager) WatchPackageRevisions(ctx context.Context, filter repos
r.mutex.Lock()
defer r.mutex.Unlock()

// reap any dead watchers
for i, watcher := range r.watchers {
if watcher == nil {
continue
}
if err := watcher.isDoneFunction(); err != nil {
klog.Infof("stopping watcher in reaper: %v", err)
r.watchers[i] = nil
continue
}
}

w := &watcher{
isDoneFunction: ctx.Err,
callback: callback,
Expand Down

0 comments on commit 5d62251

Please sign in to comment.