-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
api, cmd, policy: Show rule labels in policy selectors
output
#27838
Merged
christarazi
merged 2 commits into
cilium:main
from
christarazi:pr/christarazi/improve-policy-selector-debugging
Oct 3, 2023
Merged
api, cmd, policy: Show rule labels in policy selectors
output
#27838
christarazi
merged 2 commits into
cilium:main
from
christarazi:pr/christarazi/improve-policy-selector-debugging
Oct 3, 2023
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
3191db7
to
3b8c355
Compare
3b8c355
to
803706a
Compare
/test |
policy selectors
output
803706a
to
15d2a10
Compare
15d2a10
to
8178cfe
Compare
8178cfe
to
c593e5d
Compare
/test |
/test Edit: Hit #27688 |
tommyp1ckles
approved these changes
Sep 30, 2023
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.
Looks good, this is a really useful change 🚀
nathanjsweet
approved these changes
Oct 2, 2023
In order to make investigating the output of `cilium policy selectors` easier to understand, plumb the rule labels from KNP, CNP, and CCNPs. This makes it so that the user can very easily see which policy the selector came from. Benchmark results before and after given that selectorcache can be a hot path in the policy engine: ``` $ go test -v ./pkg/policy -run '^$' -bench 'BenchmarkRegenerateL3EgressPolicyRules' -test.benchtime 100x -test.benchmem -test.count 10 ... $ benchstat old.txt new.txt name old time/op new time/op delta RegenerateL3EgressPolicyRules-16 8.13ms ±13% 8.01ms ±11% ~ (p=0.912 n=10+10) name old alloc/op new alloc/op delta RegenerateL3EgressPolicyRules-16 1.75MB ± 0% 1.94MB ± 0% +10.78% (p=0.000 n=10+9) name old allocs/op new allocs/op delta RegenerateL3EgressPolicyRules-16 24.1k ± 0% 25.1k ± 0% +4.15% (p=0.000 n=10+10) ``` Signed-off-by: Chris Tarazi <chris@isovalent.com>
Use the functionality implemented in previous commits to output the rule labels in the selector output. This is useful for understanding which policy the selector comes from, which makes debugging issues much easier. Example output: ``` root@kind-worker:/home/cilium# cilium policy selectors SELECTOR LABELS USERS IDENTITIES &LabelSelector{MatchLabels:map[string]string{k8s.io.kubernetes.pod.namespace: kube-system,k8s.k8s-app: kube-dns,},MatchExpressions:[]LabelSelectorRequirement{},} default/tofqdn-dns-visibility 1 16500 &LabelSelector{MatchLabels:map[string]string{reserved.none: ,},MatchExpressions:[]LabelSelectorRequirement{},} default/tofqdn-dns-visibility 1 MatchName: , MatchPattern: * default/tofqdn-dns-visibility 1 16777217 16777218 16777219 ``` Signed-off-by: Chris Tarazi <chris@isovalent.com>
c593e5d
to
83019d7
Compare
/test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/cli
Impacts the command line interface of any command in the repository.
kind/enhancement
This would improve or streamline existing functionality.
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
release-note/minor
This PR changes functionality that users may find relevant to operating 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.
policy selectors
outputCommits for convenience of review:
Related: #27804