-
Notifications
You must be signed in to change notification settings - Fork 54
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
Use context consistently #165
Conversation
Codecov Report
@@ Coverage Diff @@
## master #165 +/- ##
=======================================
Coverage 44.60% 44.60%
=======================================
Files 54 54
Lines 2717 2717
=======================================
Hits 1212 1212
Misses 1259 1259
Partials 246 246
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Are we confident that this decision can grow with the Constraint Framework? What if we wanted to support another backend? Perhaps a different implementation there would benefit from the ability to cancel requests. No argument on the lack of utility at the moment, but we should be mindful of changing the public interface. Other projects (like config validator) use the constraint framework as well, and we don't want them to break unless it's for a great reason. |
We'll need to change the API as part of sharding Rego evaluation, so WRT backwards compatibility, as long as all these changes go out at once, it's probably not that much more pain. As far as for future usage, it's a fair concern. IMO we should be able to inject context into requests that can/should be interrupted b/c they can have the potential to run for a long time. |
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
Right now I'm tending towards YAGNI - since gatekeeper is the primary consumer, if we end up needing to add context back, I'd rather have to do it in the future and only add it where it's needed, than request it everywhere and just have it in places we end up never needing it. |
Eliminate all uses of context.TODO(). Eliminate all uses of context.Background() in production code. In all cases, either our callers have a Context they can pass or the k8s framework provides one. This change breaks gatekeeper - since this modifies our external APIs, making this in a non-breaking way would require 5 PRs instead of 2. Once this PR has been submitted, I'll submit a PR which updates the version of frameworks/ that gatekeeper uses and fix the resulting breakages. Signed-off-by: Will Beason <willbeason@google.com>
There were a lot of Contexts we asked for in interfaces, but didn't actually use. Since this pollutes call sites and gives the false impression that these calls are cancellable/etc, we shouldn't have them. This commit removes these unnecessary contexts. Signed-off-by: Will Beason <willbeason@google.com>
Eliminate all uses of context.TODO(). Eliminate all uses of
context.Background() in production code. In all cases, either our
callers have a Context they can pass or the k8s framework provides one.
Remove unnecessary uses of context.Context. In quite a few places we
require context.Context, but nothing actually consumes it so it's just an
unused parameter that pollutes call sites and gives the false impression
that these requests are cancellable/etc. I've removed usages of Context
in these cases.
This change breaks gatekeeper - since this modifies our external APIs,
making this in a non-breaking way would require 5 PRs instead of 2. Once
this PR has been submitted, I'll submit a PR which updates the version
of frameworks/ that gatekeeper uses and fix the resulting breakages.
Signed-off-by: Will Beason willbeason@google.com