From c1f963f7bbd0d7a121cabc423d313918f298ff09 Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Thu, 12 Oct 2023 20:17:27 +0000 Subject: [PATCH] porch: Fix watcher duplication bug (#4067) * Fix watcher duplication bug Signed-off-by: John Belamaric * Free up space on GitHub runner Signed-off-by: John Belamaric --------- Signed-off-by: John Belamaric --- .github/workflows/porch-e2e.yml | 2 ++ porch/pkg/engine/watchermanager.go | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/porch-e2e.yml b/.github/workflows/porch-e2e.yml index c80819a35..28ef88d46 100644 --- a/.github/workflows/porch-e2e.yml +++ b/.github/workflows/porch-e2e.yml @@ -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: diff --git a/porch/pkg/engine/watchermanager.go b/porch/pkg/engine/watchermanager.go index b58b588f1..f6ec874b9 100644 --- a/porch/pkg/engine/watchermanager.go +++ b/porch/pkg/engine/watchermanager.go @@ -71,10 +71,14 @@ 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 } @@ -82,9 +86,11 @@ func (r *watcherManager) WatchPackageRevisions(ctx context.Context, filter repos 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 }