[v1.14 backport] pkg/labels: print all leaf CIDRs, not just the last one. #32511
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.
Manual backport of #28224 -- pkg/labels: print all leaf CIDRs, not just the last one.
[ upstream commit 1ec121c ]
[ backporters notes: needed to shuffle files around due to renames. ]
When printing Labels (e.g. by
cilium identity list
), CIDR labels are de-expanded to only show the relevant ones. For example, the CIDR label 1.1.1.0/24 is under-the-hood expanded to 0.0.0.0/0, 0.0.0.0/1, ..., 1.1.1.0/23, 1.1.1.0/24. Then, when the identity is printed for human consumption, the CIDR labels are de-expanded. However, this code did not anticipate a single identity having multiple "leaf" CIDR labels.So, change the printing logic to output all interesting CIDRs. This adds a small utility datatype to efficiently prune a tree of cidrs to the leaves. It winds up being about 30% faster than the original, incorrect version.
Once this PR is merged, you can update the PR labels via: