Skip to content

Commit

Permalink
porch: Fix watcher duplication bug (kptdev#4067)
Browse files Browse the repository at this point in the history
* Fix watcher duplication bug

Signed-off-by: John Belamaric <jbelamaric@google.com>

* Free up space on GitHub runner

Signed-off-by: John Belamaric <jbelamaric@google.com>

---------

Signed-off-by: John Belamaric <jbelamaric@google.com>
  • Loading branch information
johnbelamaric committed Oct 12, 2023
1 parent 8b5e2f5 commit c1f963f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit c1f963f

Please sign in to comment.