-
Notifications
You must be signed in to change notification settings - Fork 727
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
Do not use context.Background() on write requests to the k8s API #5649
Conversation
Jenkins test this please |
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
cmd/manager/main.go
Outdated
gcCtx := tracing.NewContextTransaction(ctx, tracer, "garbage-collection", "on_operator_start", nil) | ||
err := garbageCollectUsers(gcCtx, cfg, managedNamespaces) | ||
if err != nil { | ||
log.Error(err, "user garbage collector failed") |
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.
Nit: we are going to log twice user garbage collector failed
:
2022-05-17T10:09:35.427+0200 ERROR manager user garbage collector failed {
"service.version": "2.3.0-SNAPSHOT+6b671559",
"error": "user garbage collector creation failed: root_error_message"
}
log.Error(err, "user garbage collector failed") | |
log.Error(err) |
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.
I think that method signature does not exist but I can adjust the message a bit to avoid the repetition.
…stic#5649) Introduces the correct context into all requests made with the k8s client-go library that do not use the cache. So the rule is: Create, Update, Delete need a correct context. List, Get do not because the cached client dismisses the context argument anyway. I added one where it was in scope but did not do additional refactoring to introduce one where there was not context in scope. The main motivation for the distinction between reads and writes is to limit scope of the refactoring somewhat.
This is preparatory work for #5467
It introduces the correct context into all requests made with the k8s client-go library that do not use the cache. So the rule is
Create
,Update
,Delete
need a correct contextList
,Get
do not because the cached client dismisses the context argument anyway. I added one where it was in scope but did not do additional refactoring to introduce one where there was no context in scope.The main motivation for the distinction between reads and writes is to limit scope of the refactoring somewhat.
This will allow us in a next step to add tracing for k8s client requests (sneak preview of how that will look like):
![Screenshot 2022-05-09 at 17 13 56](https://user-images.githubusercontent.com/697790/167441524-caa5aad5-5bb3-40c4-b494-f551ad565b7d.png)
Note for reviewers
This is probably bit of a nightmare to review given the repetitive nature of the change and large change set. Things of interest to focus on could be:
asyncTasks
that are run from the manager/main.go to introduce context and start transactions. This probably worth a closer look and also worth following into the individual tasks like the license info reporter and the telemetry reporter etc.