-
Notifications
You must be signed in to change notification settings - Fork 101
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
Contexts complient with kube-builder #204
Conversation
8bbc4e7
to
2c42b40
Compare
2c42b40
to
2820c0c
Compare
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.
Btw I was always wondering of a real difference between TODO()
vs Background()
The difference is NONE, lol
// act | ||
err := resolver.ResolveGslbSpec(gslb) | ||
err := resolver.ResolveGslbSpec(context.TODO(), gslb) |
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.
Why do we still use TODO() there?
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.
@ytsarev good question: The point is that you are creating i.e. WithCancel context from existing context.
If you use Background context, you explicitly say: Hey, I'm using context from the top of the tree, usually main package
and this context will instantiate another context(s) WithCancel
, WithDeadline
...
If you use context.TODO() you explicitly say: function just requires some context argument so I will pass TODO which is doing nothing, just to compile. For instance, our tests..
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.
@kuritka cool, makes total sense
In order to migration operator-sdk 1.0 we should use contexts to be kube-builder compliant. To achieve this, I reuse default Background context from reconciliation loop. see: https://book.kubebuilder.io/cronjob-tutorial/controller-implementation.html#implementing-a-controller;
I changed