@@ -806,19 +806,24 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error {
806
806
r .backoff .UpdateBackoff (r .URL (), err , resp .StatusCode )
807
807
}
808
808
if err != nil {
809
- // "Connection reset by peer" is usually a transient error .
809
+ // "Connection reset by peer", "Connection refused" or "apiserver is shutting down" are usually a transient errors .
810
810
// Thus in case of "GET" operations, we simply retry it.
811
811
// We are not automatically retrying "write" operations, as
812
812
// they are not idempotent.
813
- if ! net . IsConnectionReset ( err ) || r .verb != "GET" {
813
+ if r .verb != "GET" {
814
814
return err
815
815
}
816
- // For the purpose of retry, we set the artificial "retry-after" response.
817
- // TODO: Should we clean the original response if it exists?
818
- resp = & http.Response {
819
- StatusCode : http .StatusInternalServerError ,
820
- Header : http.Header {"Retry-After" : []string {"1" }},
821
- Body : ioutil .NopCloser (bytes .NewReader ([]byte {})),
816
+ // For connection errors and apiserver shutdown errors retry.
817
+ if net .IsConnectionReset (err ) || net .IsConnectionRefused (err ) {
818
+ // For the purpose of retry, we set the artificial "retry-after" response.
819
+ // TODO: Should we clean the original response if it exists?
820
+ resp = & http.Response {
821
+ StatusCode : http .StatusInternalServerError ,
822
+ Header : http.Header {"Retry-After" : []string {"1" }},
823
+ Body : ioutil .NopCloser (bytes .NewReader ([]byte {})),
824
+ }
825
+ } else {
826
+ return err
822
827
}
823
828
}
824
829
0 commit comments