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: fix the wrong error return value #1188

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Changes from all commits
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
12 changes: 6 additions & 6 deletions internal/kube/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ func (rt *retryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp
return resp, rtErr
}
if resp.StatusCode < 500 {
return resp, rtErr
return resp, nil
}
if resp.Header.Get("content-type") != "application/json" {
return resp, rtErr
return resp, nil
}
b, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return resp, rtErr
return resp, err
}

var ke kubernetesError
Expand All @@ -61,10 +61,10 @@ func (rt *retryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp
r.Seek(0, io.SeekStart)
resp.Body = io.NopCloser(r)
if err != nil {
return resp, rtErr
return resp, err
}
if ke.Code < 500 {
return resp, rtErr
return resp, nil
}
// Matches messages like "etcdserver: leader changed"
if strings.HasSuffix(ke.Message, "etcdserver: leader changed") {
Expand All @@ -74,7 +74,7 @@ func (rt *retryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp
if strings.HasSuffix(ke.Message, "raft proposal dropped") {
return rt.roundTrip(req, retry-1, resp)
}
return resp, rtErr
return resp, nil
}

type kubernetesError struct {
Expand Down