Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

porch: Fix watcher duplication bug #4067

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion porch/pkg/engine/watchermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,26 @@ func (r *watcherManager) WatchPackageRevisions(ctx context.Context, filter repos
filter: filter,
}

active := 0
// See if we have an empty slot in the watchers list
inserted := false
for i, watcher := range r.watchers {
if watcher == nil {
if watcher != nil {
active += 1
} else if !inserted {
active += 1
r.watchers[i] = w
inserted = true
}
}

if !inserted {
// We didn't slot it in to an existing slot, append it
active += 1
r.watchers = append(r.watchers, w)
}

klog.Infof("added watcher %p; there are now %d active watchers and %d slots", w, active, len(r.watchers))
return nil
}

Expand Down
Loading