Skip to content

fix: stop leaked watch streams when pool-scope metadata is removed - #2755

Open
WorrierKhushal wants to merge 1 commit into
openyurtio:masterfrom
WorrierKhushal:fix/2753-multiplexer-watch-stream-leak
Open

fix: stop leaked watch streams when pool-scope metadata is removed#2755
WorrierKhushal wants to merge 1 commit into
openyurtio:masterfrom
WorrierKhushal:fix/2753-multiplexer-watch-stream-leak

Conversation

@WorrierKhushal

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

MultiplexerManager.updateLeaderHubConfiguration was supposed to tear
down watch streams for resources removed from pool-scoped-metadata,
but it was querying two dead fields (lazyLoadedGVRCache,
lazyLoadedGVRCacheDestroyFunc) left over from a past refactor — these
were initialized but never populated anywhere, so the cleanup logic
never actually ran. Meanwhile, the real cache instances live in
filterStoreManager, but DeleteFilterStore only removed the map entry
without calling Destroy() on the underlying filterStore, so the
watch stream and its resources (goroutines, memory, network connection)
kept running indefinitely even after the resource was removed from
pool-scoped-metadata.

This PR:

  • Makes filterStoreManager.DeleteFilterStore call fs.Destroy()
    before removing the entry.
  • Updates updateLeaderHubConfiguration to call
    m.filterStoreManager.DeleteFilterStore(gvrStr) directly instead of
    the dead-map logic.
  • Removes the now-unused lazyLoadedGVRCache /
    lazyLoadedGVRCacheDestroyFunc fields.

Added a test verifying that removing a GVR from pool-scoped-metadata
actually invokes Destroy() on its filter store.

Which issue(s) this PR fixes:

Fixes #2753

Special notes for your reviewer:

  • go test -v ./pkg/yurthub/multiplexer/... — all tests pass, including the new one
  • GOOS=linux go build ./... and go vet ./pkg/yurthub/multiplexer/... — both clean
  • grep -r "lazyLoadedGVRCache" pkg/yurthub/ — zero remaining references, confirming safe removal
  • No exported function signatures changed

Does this PR introduce a user-facing change?

NONE

other Note

@WorrierKhushal
WorrierKhushal requested a review from a team as a code owner August 15, 2026 22:46
@sonarqubecloud

Copy link
Copy Markdown

@WorrierKhushal

Copy link
Copy Markdown
Contributor Author

Hi @rambohe-ch @luc99hen @wawlian @carolove Sir i am khushal ,

I have submitted a pull request fixing issue #2753 ([BUG] Multiplexer watch streams leak indefinitely when pool-scope metadata is removed from Leader Hub ConfigMap).

Key Fix Details:

  • Implemented explicit fs.Destroy() inside DeleteFilterStore before map cleanup to release goroutines, memory, and active network connections.
  • Refactored updateLeaderHubConfiguration to use DeleteFilterStore directly and purged legacy unpopulated fields (lazyLoadedGVRCache).
  • Added unit test verification under pkg/yurthub/multiplexer/ to ensure stream teardown when GVR is removed.

All tests (go test -v ./pkg/yurthub/multiplexer/...), go vet, and cross-compilation (GOOS=linux go build ./...) pass cleanly without errors.

Whenever you have some time, could you please take a look and share your feedback? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Multiplexer watch streams leak indefinitely when pool-scope metadata is removed from Leader Hub ConfigMap

1 participant