-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix bug that skips other selectors if ToEndpoints is empty #33439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix LGTM, thanks! 💯
Left a suggestion to adapt the test after #33439 made L4PolicyMap
an interface.
32a5910
to
69c22b0
Compare
As reported in cilium#33432, when the user applies a new policy with ToCIDR set and ToEndpoints explicitly empty, the ToCIDR section is ignored by the policy. Add a test to show that this is incorrect. The subsequent commit will fix the behavior. Signed-off-by: Chris Tarazi <chris@isovalent.com>
As reported in ciliumGH-33432, do not skip other selectors in the case ToEndpoints is empty. For example, if the user defined a ToCIDR with an empty ToEndpoints, then getDestinationEndpointSelectorsWithRequirements() / GetSourceEndpointSelectorsWithRequirements() returns nil, causing the ToCIDRs section to be skipped. Instead, return the aggregated selectors, which aggregates selectors such as ToCIDRs, prior to the call to the aforementioned functions inside SetAggregatedSelectors(). Fixes: e97df7b ("policy: Do not select any identity with ingress empty slices") Fixes: 6ccd044 ("policy: Do not select any identity with egress empty slices") Fixes: cilium#29608 Signed-off-by: Chris Tarazi <chris@isovalent.com>
beef887
to
68e810d
Compare
/test |
I investigated in more detail the issue and I believe this is not what we want. This fix successfully equates the two cases:
But it does that in a way that reverts what #29608 fixed. The failed tests reflects this (as an example, see In other words, as suggested in the issue, the correct behavior should be that the two scenarios above ("direct" apply of the final version of the policy and apply+update) both lead to the policy denying connections to ExpectedThe behaviour should be consistent regardless of the order of operation on a policy.
This is not happening with the proposed fix, that allows the To get the expected behavior I think the solution should be this one, where we change the logic to compare EgressCommonRule and IngressCommonRule instances, taking into account the different semantic of nil and empty slices and propagating the update in the scenario above as expected. |
Closing in favor of #33506 |
Second commit for convenience:
Fixes: #29608
cc @pippolo84