When we see an `ECONNREFUSED` (or equivalent) from an attempted `HEAD` on the
`/_ping` endpoint there is no point in trying again with `GET` since the server
is not responding/available at all.
Once vendored into the cli this will partially mitigate https://github.com/docker/cli/issues/1739
("Docker commands take 1 minute to timeout if context endpoint is unreachable")
by cutting the effective timeout in half.
Signed-off-by: Ian Campbell <ijc@docker.com>
| ... | ... |
@@ -31,6 +31,8 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
|
| 31 | 31 |
// Server handled the request, so parse the response |
| 32 | 32 |
return parsePingResponse(cli, serverResp) |
| 33 | 33 |
} |
| 34 |
+ } else if IsErrConnectionFailed(err) {
|
|
| 35 |
+ return ping, err |
|
| 34 | 36 |
} |
| 35 | 37 |
|
| 36 | 38 |
req, err = cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil)
|