Only combine Rules Endpoints with the same CIDR if they share identical Exception lists #193
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.
Only combine Rules Endpoints with the same CIDR if they share identical Exception lists. Currently, Rules Endpoints are combined if the share the same CIDR, however, some of these Endpoints are incompatible when combined with each other.
The example from #146 shows a
NetworkPolicywith 2 Egress Rules, one allowing egress out to 0.0.0.0/0 except to CIDRs10.0.0.0/8,172.16.0.0/12, and192.168.0.0/16. The second rule allowing all egress traffic out for TCP and UDP on Port 53. Both rules egress out0.0.0.0/0and so the controller merges their internal representation. However, this is contradictory, as the second rule should allow Port 53 (DNS) traffic to any CIDR, including the ones mentioned in theexceptlist of Rule 1.Note: This undoes a lot of #80, so we need to consider the performance impact of making this operation more expensive by doing this.
Rule:
This is again visible from #146 in the
PolicyEndpointwhere the two separate rules appear merged under the single 0.0.0.0/0 Egress Rule.The code is changed to only combine Rules Endpoints with the same CIDR if they share identical Exception lists.
What type of PR is this?
Bug Fix.
Which issue does this PR fix: #146
What does this PR do / Why do we need it: Only combine Rules Endpoints with the same CIDR if they share identical Exception lists. Currently, incompatible rules are being merged.
Testing done on this change:
BEFORE:
AFTER:
Test Cluster
BEFORE:
After:
Automation added to e2e: N/A
Will this PR introduce any new dependencies?: No.
Will this break upgrades or downgrades. Has updating a running cluster been tested?: No. N/A.
Does this PR introduce any user-facing change?: No, just a bug fix.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.