-
Notifications
You must be signed in to change notification settings - Fork 326
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
[NET-5399] Improve token fetching performance for endpoints controller. #2910
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
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 |
count++ | ||
} | ||
} | ||
require.Greater(r, count, 0) |
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.
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.
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.
LGTM!
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.
LGTM too!
tokens, _, err := apiClient.ACL().TokenList(&api.QueryOptions{ | ||
Namespace: svc.Namespace, | ||
}) | ||
// Note that while the `TokenListFiltered` query below should only return a subset |
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.
Thanks for the comment!
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=mysvc
does 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=mysvc
returns the proper subset of tokens on a consul-k8s install using this new build.How I expect reviewers to test this PR:
Checklist: