policy: Replace versioned with part.Map redux#43279
Merged
jrajahalme merged 3 commits intocilium:mainfrom Dec 16, 2025
Merged
Conversation
Member
Author
|
/test |
sayboras
approved these changes
Dec 12, 2025
nebril
approved these changes
Dec 12, 2025
Member
Author
|
/ci-l3-l4 |
Member
Author
|
/ci-l7 |
gandro
approved these changes
Dec 15, 2025
Member
gandro
left a comment
There was a problem hiding this comment.
I didn't re-review the first commit in detail given it was already functionally reviewed. The test changes seem good to me. Thanks!
squeed
reviewed
Dec 15, 2025
pippolo84
approved these changes
Dec 15, 2025
This reverts commit 206d042. Signed-off-by: Jarno Rajahalme <[email protected]>
Add a done channel to allow test code to terminate the incremental update handler goroutine. This prevents leaking of goroutines in the test suite, which is especially bad if tests are repeated multiple times. The handler is never stopped in production to avoid the associated failure modes (handler stopping when it should not, etc.). Signed-off-by: Jarno Rajahalme <[email protected]>
Perform sanity checks on the cached selector selections only after the corresponding snapshot is delivered via commit. Fixes: cilium#42992 Signed-off-by: Jarno Rajahalme <[email protected]>
77040f1 to
e5c8323
Compare
Member
Author
|
/test |
Member
Author
|
rebased and changed to use |
squeed
approved these changes
Dec 15, 2025
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#43237 reverted the last commit of #42992 due to a new unit test flake.
This PR reapplies the reverted commit as-is (1st commit) and adds two unit test fixes:
policy: Terminate incremental notification handlers in testsReturn a
closerfunction from test infra returning new SelectorCache instances, so that the test can callcloser()to terminate the incremental update notification handler goroutine, if one was started for the SelectorCache instance. This eliminates leaked goroutines which take both resources and complicatego testoutput in error situations such as test timeouts.policy: Defer test validations of selector notifications till commitThe commit changes the test tooling for the mock
cachedSelectionUser, noTestcode is changed otherwise. The rationale for the change is that the mock was accessing the current version of the selected identities viaselector.GetSelections(), while it really should postpone this access untilIdentitySelectionCommit()is called (as that is the time the user gets a handle to the version where the changes were applied) and use that version explicitly (selector.GetSelectionsAt(...)).Production implementation (in
pkg/policy/mapstate.go) is already doing the right thing.Previously the selection updates were always done prior
IdentitySelectionUpdated()was called, but with the change in thepolicy: Replace versioned with part.Mapcommit the publication of the changes is done later, but always prior to theIdentitySelectionCommit()call. This results in a race, where sometimes the update on the selector selections is not yet available when theIdentitySelectionUpdated()callback executes (in a different goroutine). If the execution of the notifications was synchronous then the associated tests would always fail without this fix.This test can be used to validate the fix:
main(with the already merged revert) this test should passFixes: #42992
Fixes: #43237