-
Notifications
You must be signed in to change notification settings - Fork 614
[apiserver] Add retry and timeout to apiserver V2 #3869
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
Conversation
@dentiny PTAL, thanks! |
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 don't see any unit tests, curious how did you test it?
Currently my implementation logs the error message to I test with the following steps
|
However, this may not work for the case that we wrapped error message into error |
@dentiny PTAL, thanks! |
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!
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
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Co-authored-by: dentiny <[email protected]> Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
…uration Signed-off-by: Cheng-Yeh Chung <[email protected]>
apiserversdk/proxy.go
Outdated
|
||
if attempt > 0 && req.GetBody != nil { | ||
var bodyCopy io.ReadCloser | ||
bodyCopy, err = req.GetBody() |
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.
Do we still need to use req.GetBody()?
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.
Because req.Body
in go is an one-time streamer, which can only be used once, we need to regenerate a new body for the retries by req.GetBody()
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.
You think can just use req.Body = io.NopCloser(bytes.NewReader(bodyBytes))
once you move bodyBytes, err = io.ReadAll(req.Body)
out of the loop.
…ng cancelled during backoff Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
apiserversdk/proxy.go
Outdated
if attempt > 0 && req.GetBody != nil { | ||
req.Body = io.NopCloser(bytes.NewReader(bodyBytes)) | ||
} |
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.
if attempt > 0 && req.GetBody != nil { | |
req.Body = io.NopCloser(bytes.NewReader(bodyBytes)) | |
} | |
if bodyBytes != nil { | |
req.Body = io.NopCloser(bytes.NewReader(bodyBytes)) | |
} |
Could you add a test that uses req.Body as well?
Co-authored-by: Rueian <[email protected]> Signed-off-by: Cheng-Yeh Chung <[email protected]>
Co-authored-by: Rueian <[email protected]> Signed-off-by: Cheng-Yeh Chung <[email protected]>
Signed-off-by: Cheng-Yeh Chung <[email protected]>
Thanks @kenchung285! |
Why are these changes needed?
Add retry logic and timeout to apiserver v2:
Wrap errors with more informations
Related issue number
Closes #3606
Checks