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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .github/workflows/porch-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:
- "kindest/node:v1.23.4@sha256:0e34f0d0fd448aa2f2819cfd74e99fe5793a6e4938b328f657c8e3f81ee0dfb9"

steps:
- name: Free up disk space
run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up Go
uses: actions/setup-go@v3
with:
Expand Down
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