Skip to content

fix(yurthub): fix filtermanager state divergence and reset logic for … - #2768

Open
WorrierKhushal wants to merge 5 commits into
openyurtio:masterfrom
WorrierKhushal:fix/2767-filtermanager-state-divergence
Open

fix(yurthub): fix filtermanager state divergence and reset logic for …#2768
WorrierKhushal wants to merge 5 commits into
openyurtio:masterfrom
WorrierKhushal:fix/2767-filtermanager-state-divergence

Conversation

@WorrierKhushal

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

When the yurt-hub-cfg ConfigMap is updated at runtime, pkg/yurthub/configuration.Manager updates its internal state, but the active FilterManager instance (nameToObjectFilter and resourceSyncers) was never re-initialized or notified of the change.

This mismatch caused a silent state divergence between control-plane configuration and active edge proxy handling, forcing administrators to completely restart YurtHub instances to apply configuration updates.

This PR:

  • Introduces an AddListener and notifyListeners mechanism in configuration.Manager so components can register for config-change notifications.
  • Implements a safe Reset method on FilterManager protected by a mutex lock, which stops existing resource syncers to prevent goroutine/watch leaks, rebuilds filters, and safely swaps state.
  • Wires FilterManager.Reset during YurtHub startup so runtime yurt-hub-cfg reloads automatically and dynamically re-syncs active filters and resource syncers without requiring a process restart.
  • Cleans up fake_filtermanager.go and updates tests (manager_test.go) to match the simplified Reset signature.

Fixes #2767

Verified locally with:

go test ./pkg/yurthub/filter/manager/... -v
go test ./pkg/yurthub/configuration/... -v
go vet ./pkg/yurthub/filter/...

@WorrierKhushal
WorrierKhushal requested a review from a team as a code owner August 26, 2026 09:00
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.21687% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.16%. Comparing base (ddf22f7) to head (5e8f07a).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
pkg/yurthub/util/dumpstack.go 0.00% 20 Missing ⚠️
pkg/yurthub/configuration/manager.go 33.33% 5 Missing and 1 partial ⚠️
pkg/yurthub/filter/manager/manager.go 89.36% 3 Missing and 2 partials ⚠️
...ub/proxy/multiplexer/testing/fake_filtermanager.go 0.00% 4 Missing ⚠️
cmd/yurthub/app/config/config.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2768      +/-   ##
==========================================
- Coverage   46.20%   46.16%   -0.04%     
==========================================
  Files         405      405              
  Lines       27540    27628      +88     
==========================================
+ Hits        12724    12755      +31     
- Misses      13649    13698      +49     
- Partials     1167     1175       +8     
Flag Coverage Δ
unittests 46.16% <54.21%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@WorrierKhushal

Copy link
Copy Markdown
Contributor Author

Hi maintainers @zyjhtangtang sir ,

I have resolved the filtermanager state divergence issue and cleaned up all the linter checks (including the recent formatting checks). All CI actions and tests are now passing successfully.

Could you please take a look and review this PR when you get a chance?

Thank you!

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] FilterManager state diverges from dynamic configuration updates in yurt-hub-cfg ConfigMap

1 participant