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

identity: make GetAllReservedIdentities() return ordered identities #20048

Conversation

kaworu
Copy link
Member

@kaworu kaworu commented Jun 1, 2022

Before this patch, the returned slice from GetAllReservedIdentities() was inconsistently ordered.

This was caused by the fact that the resulting slice is built from iterating over a go map, and "the iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next. […]", see the Go language spec.

See cilium/hubble#732 for more context.

@kaworu kaworu added area/misc Impacts miscellaneous areas of the code not otherwise owned by another area. release-note/misc This PR makes changes that have no direct user impact. labels Jun 1, 2022
@kaworu kaworu requested review from a team and jrajahalme June 1, 2022 17:39
@kaworu kaworu force-pushed the pr/kaworu/identity/GetAllReservedIdentities-order branch from 24724cc to e1a630c Compare June 2, 2022 15:41
Copy link
Member

@jrajahalme jrajahalme left a comment

Choose a reason for hiding this comment

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

Looks good, but it looks to me this function is not used for anything, so maybe we should just delete it instead?

@kaworu kaworu force-pushed the pr/kaworu/identity/GetAllReservedIdentities-order branch from e1a630c to 5e7be46 Compare June 20, 2022 09:47
@kaworu
Copy link
Member Author

kaworu commented Jun 20, 2022

@jrajahalme correct it is unused in this repo, but the Hubble CLI uses it (see the PR's description for a link to the relevant code). I've added a comment so that it doesn't get removed.

Before this patch, the returned slice from GetAllReservedIdentities()
was inconsistently ordered.

This was caused by the fact that the resulting slice is built from
iterating over a go map, and "the iteration order over maps is not
specified and is not guaranteed to be the same from one iteration to the
next. […]", see the Go language spec[1].

[1]: https://go.dev/ref/spec#For_statements

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
@kaworu kaworu requested a review from jrajahalme June 20, 2022 10:07
@kaworu
Copy link
Member Author

kaworu commented Jun 30, 2022

As stated above, GetAllReservedIdentities() is unused by Cilium and thus not covered by CI besides the unit test introduced by this PR. Marking as ready to merge since the Travis CI workflow passed.

@kaworu kaworu added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jun 30, 2022
@kaworu kaworu requested a review from a team June 30, 2022 14:54
@qmonnet qmonnet merged commit 19bda87 into cilium:master Jun 30, 2022
@kaworu kaworu deleted the pr/kaworu/identity/GetAllReservedIdentities-order branch July 1, 2022 15:18
kaworu added a commit to cilium/hubble that referenced this pull request Oct 13, 2022
Now that we vendor a version of Cilium including
cilium/cilium#20048
identity.GetAllReservedIdentities() consistently returned a sorted list
already.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
rolinh pushed a commit to cilium/hubble that referenced this pull request Oct 13, 2022
Now that we vendor a version of Cilium including
cilium/cilium#20048
identity.GetAllReservedIdentities() consistently returned a sorted list
already.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/misc Impacts miscellaneous areas of the code not otherwise owned by another area. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants