Skip to content

Commit c1f963f

Browse files
porch: Fix watcher duplication bug (#4067)
* Fix watcher duplication bug Signed-off-by: John Belamaric <[email protected]> * Free up space on GitHub runner Signed-off-by: John Belamaric <[email protected]> --------- Signed-off-by: John Belamaric <[email protected]>
1 parent 8b5e2f5 commit c1f963f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.github/workflows/porch-e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
- "kindest/node:v1.23.4@sha256:0e34f0d0fd448aa2f2819cfd74e99fe5793a6e4938b328f657c8e3f81ee0dfb9"
5454

5555
steps:
56+
- name: Free up disk space
57+
run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
5658
- name: Set up Go
5759
uses: actions/setup-go@v3
5860
with:

porch/pkg/engine/watchermanager.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,26 @@ func (r *watcherManager) WatchPackageRevisions(ctx context.Context, filter repos
7171
filter: filter,
7272
}
7373

74+
active := 0
7475
// See if we have an empty slot in the watchers list
7576
inserted := false
7677
for i, watcher := range r.watchers {
77-
if watcher == nil {
78+
if watcher != nil {
79+
active += 1
80+
} else if !inserted {
81+
active += 1
7882
r.watchers[i] = w
7983
inserted = true
8084
}
8185
}
8286

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

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

0 commit comments

Comments
 (0)