[NET-5399] Improve token fetching performance for endpoints controller.#2910
Merged
hashi-derek merged 3 commits intomainfrom Sep 8, 2023
Merged
[NET-5399] Improve token fetching performance for endpoints controller.#2910hashi-derek merged 3 commits intomainfrom
hashi-derek merged 3 commits intomainfrom
Conversation
Prior to this change, the endpoints controller would list all ACL tokens in a namespace when a service instance is being deleted. This commit improves the performance by querying only the necessary subset of tokens by service-identity / service-name.
6f37bfd to
3c4b8f9
Compare
Contributor
Author
|
This PR is marked as no-backport due to go.mod changes. There will be manual backports created for 1.0.X -> 1.2.X |
hashi-derek
commented
Sep 8, 2023
| count++ | ||
| } | ||
| } | ||
| require.Greater(r, count, 0) |
Contributor
Author
There was a problem hiding this comment.
Another assertion exists further down that ensures the token is deleted properly. This was just added here to make sure that the token exists in the first place.
wilkermichael
approved these changes
Sep 8, 2023
| tokens, _, err := apiClient.ACL().TokenList(&api.QueryOptions{ | ||
| Namespace: svc.Namespace, | ||
| }) | ||
| // Note that while the `TokenListFiltered` query below should only return a subset |
Contributor
There was a problem hiding this comment.
Thanks for the comment!
This was referenced Sep 11, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prior to this change, the endpoints controller would list all ACL tokens in a namespace when a service instance is being deleted. This commit improves the performance by querying only the necessary subset of tokens by service-identity / service-name.
Changes proposed in this PR:
How I've tested this PR:
/v1/acl/tokens?servicename=mysvcdoes not throw an error on prior versions of Consul 1.16 and simply returns the full list of tokens. This means that updating consul-k8s to use the new query param will still be backwards compatible (because it can still loop and filter on the full list of tokens in-memory, rather than looping on the subset)./v1/acl/tokens?servicename=mysvcreturns the proper subset of tokens on a consul-k8s install using this new build.How I expect reviewers to test this PR:
Checklist: