Skip to content
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

Print full labelset for all identities in 'cilium ip list' output #28425

Merged
merged 4 commits into from Oct 12, 2023

Conversation

joestringer
Copy link
Member

@joestringer joestringer commented Oct 5, 2023

The host identity can have multiple labels that are not hardcoded directly from
the number, so we should just always fetch the full labelset from the agent for
all identities to ensure that the CLI prints what the agent knows. No need for
special cases for reserved identities.

Technically this bug goes way back and impacts any version since the kube-apiserver
entity policy feature has existed, but it's a minor bug so I'm only proposing this
for 1.14 at this time.

@joestringer joestringer requested a review from a team as a code owner October 5, 2023 15:38
@joestringer joestringer added release-note/bug This PR fixes an issue in a previous release of Cilium. needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch labels Oct 5, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. and removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Oct 5, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.14.3 Oct 5, 2023
@joestringer joestringer added affects/v1.12 This issue affects v1.12 branch affects/v1.13 This issue affects v1.13 branch affects/v1.14 This issue affects v1.14 branch labels Oct 5, 2023
@joestringer
Copy link
Member Author

/test

Copy link
Member

@christarazi christarazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@christarazi christarazi added the area/cli Impacts the command line interface of any command in the repository. label Oct 5, 2023
cilium/cmd/ip_list.go Outdated Show resolved Hide resolved
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Oct 6, 2023
Copy link
Contributor

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joestringer Nice work!

@joestringer
Copy link
Member Author

All required tests passing and reviews are in. I'll fix up the minor nit from Fernand and repush. Should be good to merge after that.

If the 'cilium ip list' command cannot fetch identities for some numeric
identities, then print an error and continue. This way it should still
be possible to view most of the ips and at least their numeric identity
counterparts even if one of the identities' labels cannot be queried.

Signed-off-by: Joe Stringer <joe@cilium.io>
No need to iterate the labels here and individually append them to the
slice, there's GetPrintableModel() for this purpose.

Signed-off-by: Joe Stringer <joe@cilium.io>
In particular the host identity can have multiple labels that are not
hardcoded directly from the number, so we should just always fetch the
full labelset from the agent to ensure that the CLI prints what the
agent knows. No special cases for reserved identities.

The main subtlety here is that the GetIdentityIDParams() input is always
the numeric identity as a string, and never the stringified name of that
identity. For instance if client-side the CLI thinks that it can map
identity "1" to "host" then it will still make the query with the
parameter "1" (since that's how the identity get API works). If the
query fails, then it'll attempt to fall back to printing a stringified
name like "host" if available client-side, or otherwise just print the
number.

Signed-off-by: Joe Stringer <joe@cilium.io>
A single IP can only have exactly one identity. Each identity can have a
set of labels associated with it. This code was confusingly using the
variable name 'identities' for individual labels within a single
identity. Rename it for clarity.

(Strictly speaking the labels may not actually be labels but may be the
numeric identity if the user decided not to pretty-print the labels, but
I think this variable naming is still more clear than what preceded it).

Signed-off-by: Joe Stringer <joe@cilium.io>
@joestringer
Copy link
Member Author

/test

@squeed
Copy link
Contributor

squeed commented Oct 12, 2023

All required tests are passing, button is green. Merging.

@squeed
Copy link
Contributor

squeed commented Oct 12, 2023

Oh wait, I'll let @joestringer do the honors.

@joestringer joestringer merged commit fafd535 into main Oct 12, 2023
206 of 210 checks passed
@joestringer joestringer deleted the pr/joe/fix-ip-list-host-labels branch October 12, 2023 16:52
@jrajahalme jrajahalme added this to Needs backport from main in 1.14.4 Oct 18, 2023
@jrajahalme jrajahalme removed this from Needs backport from main in 1.14.3 Oct 18, 2023
@tklauser tklauser added backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. and removed needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch labels Oct 24, 2023
@tklauser tklauser mentioned this pull request Oct 24, 2023
14 tasks
@tklauser tklauser added backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. and removed backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. labels Oct 25, 2023
@thorn3r thorn3r moved this from Needs backport from main to Backport done to v1.14 in 1.14.4 Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/v1.12 This issue affects v1.12 branch affects/v1.13 This issue affects v1.13 branch affects/v1.14 This issue affects v1.14 branch area/cli Impacts the command line interface of any command in the repository. backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
No open projects
1.14.4
Backport done to v1.14
Development

Successfully merging this pull request may close these issues.

None yet

5 participants