-
Notifications
You must be signed in to change notification settings - Fork 21
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
Handle the context in webhook #75
base: main
Are you sure you want to change the base?
Handle the context in webhook #75
Conversation
Signed-off-by: Michel Hollands <[email protected]>
Signed-off-by: Michel Hollands <[email protected]>
Signed-off-by: Michel Hollands <[email protected]>
bde3899
to
5e60a3c
Compare
select { | ||
case <-ctx.Done(): | ||
return nil, ctx.Err() | ||
default: | ||
} | ||
|
||
switch ar.Request.Resource.Resource { |
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 is this needed? All the calls below have the contexts provided.
It is usually unneeded to add the |
select { | ||
case <-ctx.Done(): | ||
return nil, ctx.Err() | ||
default: | ||
} |
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.
Also, this is shorter and equivalent:
select { | |
case <-ctx.Done(): | |
return nil, ctx.Err() | |
default: | |
} | |
if err := ctx.Err(); err != nil { | |
return nil, err | |
} |
@colega Sorry, I should have left this as a draft PR. We are having a problem with the prepareDownscale webhook on AWS and Azure where it returns |
This will stop the request from adding an annotation to the statefulset if the context is cancelled.