Skip to content
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

fix(executor): Retry kubectl on internal transient error #8092

Merged
merged 3 commits into from
Mar 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(executor): Retry kubectl on internal transient error
fix(executor): Retry kubectl on internal transient error
Signed-off-by: wujayway <[email protected]>
  • Loading branch information
wujayway committed Mar 7, 2022
commit 5f001b8364e5178b99068f738b61984e7f0596ea
15 changes: 10 additions & 5 deletions util/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func matchTransientErrPattern(err error) bool {
if pattern == "" {
return false
}
match, _ := regexp.MatchString(pattern, err.Error())
match, _ := regexp.MatchString(pattern, generateErrorString(err))
return match
}

Expand All @@ -63,10 +63,7 @@ func isTransientNetworkErr(err error) bool {
}
}

errorString := err.Error()
if exitErr, ok := err.(*exec.ExitError); ok {
errorString = fmt.Sprintf("%s %s", errorString, exitErr.Stderr)
}
errorString := generateErrorString(err)
if strings.Contains(errorString, "net/http: TLS handshake timeout") {
// If error is - tlsHandshakeTimeoutError, retry.
return true
Expand All @@ -80,3 +77,11 @@ func isTransientNetworkErr(err error) bool {

return false
}

func generateErrorString(err error) string {
errorString := err.Error()
if exitErr, ok := err.(*exec.ExitError); ok {
errorString = fmt.Sprintf("%s %s", errorString, exitErr.Stderr)
}
return errorString
}
Comment on lines +81 to +87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok