Add the http2 GOAWAY error to IsProbableEOF for ignoring in watch

http2 is allowed to tell us to go away, and for watch it is safe
to exit and restart in almost all cases where a connection is
forcibly closed by the upstream. This error message happens a lot
behind ELB and other http2 aware proxies.

Treat the error as "basically done" as suggested by

https://github.com/golang/go/issues/18639#issuecomment-285515534
This commit is contained in:
Clayton Coleman 2019-01-24 09:59:33 -05:00
parent 2cd88258c7
commit 640caeb74f
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -68,14 +68,17 @@ func IsProbableEOF(err error) bool {
if uerr, ok := err.(*url.Error); ok {
err = uerr.Err
}
msg := err.Error()
switch {
case err == io.EOF:
return true
case err.Error() == "http: can't write HTTP request on broken connection":
case msg == "http: can't write HTTP request on broken connection":
return true
case strings.Contains(err.Error(), "connection reset by peer"):
case strings.Contains(msg, "http2: server sent GOAWAY and closed the connection"):
return true
case strings.Contains(strings.ToLower(err.Error()), "use of closed network connection"):
case strings.Contains(msg, "connection reset by peer"):
return true
case strings.Contains(strings.ToLower(msg), "use of closed network connection"):
return true
}
return false