-
Notifications
You must be signed in to change notification settings - Fork 263
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.Context in API methods #1274
Use context.Context in API methods #1274
Conversation
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Welcome @matejvasek! It looks like this is your first PR to knative/client 🎉 |
Hi @matejvasek. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @rhuss @navidshaikh |
We also need to make changes to the eventing client interface and maybe some others. |
Signed-off-by: Matej Vasek <[email protected]>
c40d3dc
to
9598646
Compare
@rhuss what subcommands of |
/ok-to-test |
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
@navidshaikh please another /ok-to-test |
@navidshaikh prow bot doesn't run the tests on |
@dsimansk it did run some integration tests after @navidshaikh set the ok to test label. Latter I committed new stuff, but the integration tests were not run. 🤷♂️ |
Well, one ok should be enough, plus there's a label now etc. /ok-to-test |
@dsimansk please run test again, I did small fix. |
Should I care about that coverage? |
It'd better if there was a test for new signals handling in I've found only one leftover |
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.
Truly appreciate the effort. But I’ll also opine how much I hate the pollution
that entails, especially for context.TODO()
. Oh well, I guess somethings in life you just live with.
Thanks @matejvasek for the hard work on this. Cheers 🍻
@maximilien I don't like that pollution too. But if there is no func getFoo(ctx context.Context) ([]byte, error) {
ch := make(chan struct {
f []byte
e error
})
go func() {
foo, err := xyz.getFoo()
ch <- struct {
f []byte
e error
}{f: foo, e: err}
}()
select {
case res := <-ch:
return res.f, res.e
case <-ctx.Done():
return nil, ctx.Err()
}
} which is not nice. In addition many interfaces use |
I agree that the context passing in the argument list is not nice, but it's golang way of passing context (in contrast to Java where you probably would have used a ThreadLocal for this). And as @matejvasek mentioned, Docker and Kubernetes changed to this style, too, so we are in good company. |
Thanks @matejvasek for the PR, very nice :-) Unfortunately, I don't have spare cycles for a review this week, but that's no loss since @maximilien @navidshaikh @dsimansk are excellent reviewers :) |
Most of the changes here are mechanical done by |
/assign |
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!
I've commented inline on a few files, but the following changes need to be done for each client:
- For each individual clients,
- Remove the context arg for individual
Namespace()
as it's an accessor (the ns is set via factory while creating the respective client) - for eg: see review for filepkg/messaging/v1beta1/channels_client.go
- Use
ctx := context.Background()
and pass along thectx
to the chain of calls inclient_mock_test.go
- for eg: see review for filepkg/dynamic/client_mock_test.go
-
Thanks for taking care of signal handling, can we take it off from this PR and have it in subsequent one ? :-)
-
Please add an entry in changelog https://github.com/knative/client/blob/main/CHANGELOG.adoc
@matejvasek : are you seeing this while updating |
@navidshaikh yes I do (just sometimes, depending on when cancel happened). |
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
This reverts commit 9598646. Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
Signed-off-by: Matej Vasek <[email protected]>
I noticed that, but since it's not in client API I decided to leave it alone. |
Signed-off-by: Matej Vasek <[email protected]>
The following is the coverage report on the affected files.
|
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
w00t! Thanks a lot @matejvasek for quick turn around on it and adding tests!
Next set of action items would be to update the plugins consuming client APIs, if any.
/cc: @zhanggbj @maximilien @christophd @zhangtbj @dsimansk @rhuss
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: navidshaikh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Make API functions accept
context.Context
as the first argument.Reference
Fixes #1272