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
pkg/policy: remove fromEntities and toEntities from rule type #3375
Merged
Conversation
This file contains 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
Due to a regression introduced with the calling of rule sanitization functions, rule.sanitize() (different than Rule.sanitize) was never called at runtime, only during unit tests. As a result, any rule with toEntities or fromEntities was not properly populated during runtime. This was because the type pkg/policy:rule only populated these fields during rule.sanitize(), which as mentioned before, was not called outside of unit tests. Remove the toEntities and fromEntities fields, and just use the ToEntities and FromEntities within Rule.Ingress and Rule.Egress accordingly. While this involves a map lookup to map entities to their corresponding EndpointSelector, this means that we now only have one code path for validating rules; having multiple ones, as shown by the regression, is error-prone. Update the policy resolution functions to account for this change, as well as unit tests. Signed-off by: Ian Vernon <ian@cilium.io>
ianvernon
added
sig/policy
Impacts whether traffic is allowed or denied based on user-defined policies.
priority/1.0-blocker
labels
Mar 29, 2018
test-me-please |
eloycoto
added
the
needs/e2e-test
This issue is not covered by existing CI tests, but should be.
label
Mar 29, 2018
16 tasks
rlenglet
approved these changes
Mar 29, 2018
raybejjani
approved these changes
Mar 29, 2018
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.
Please make more PRs like this. I will buy you ice-cream and coffee. :)
Tested the branch locally and it works as expected |
test-me-please |
Failing test unrelated:
https://jenkins.cilium.io/job/Cilium-PR-Ginkgo-Tests-Validated/1728/console Fixed by #3333 |
tgraf
added
the
release-note/bug
This PR fixes an issue in a previous release of Cilium.
label
Apr 2, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
needs/e2e-test
This issue is not covered by existing CI tests, but should be.
release-note/bug
This PR fixes an issue in a previous release of Cilium.
sig/policy
Impacts whether traffic is allowed or denied based on user-defined policies.
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.
Due to a regression introduced with the calling of rule sanitization functions,
rule.sanitize() (different than Rule.sanitize) was never called at runtime,
only during unit tests. As a result, any rule with toEntities or fromEntities
was not properly populated during runtime. This was because the type
pkg/policy:rule only populated these fields during rule.sanitize(), which as
mentioned before, was not called outside of unit tests. Remove the toEntities
and fromEntities fields, and just use the ToEntities and FromEntities within
Rule.Ingress and Rule.Egress accordingly. While this involves a map lookup
to map entities to their corresponding EndpointSelector, this means that we now
only have one code path for validating rules; having multiple ones, as shown
by the regression, is error-prone. Update the policy resolution functions
to account for this change, as well as unit tests.
Signed-off by: Ian Vernon ian@cilium.io
Fixes: #3358
Testing done:
Manually tested. This needs CI end-to-end coverage ASAP so we do not face regressions like this again! Will work on adding those ASAP.