From 9669fe61371ff777d9bf0f8ce069a614ea51fdf0 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Mon, 13 May 2019 13:48:17 +0100 Subject: [PATCH] client: do not fallback to GET if HEAD on _ping fail to connect 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 Upstream-commit: 8c8457b0f2f85d58c0e1a5b4a0e174d7808cf886 Component: engine --- components/engine/client/ping.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/engine/client/ping.go b/components/engine/client/ping.go index 4553e0fb718..90f39ec14f9 100644 --- a/components/engine/client/ping.go +++ b/components/engine/client/ping.go @@ -31,6 +31,8 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { // Server handled the request, so parse the response return parsePingResponse(cli, serverResp) } + } else if IsErrConnectionFailed(err) { + return ping, err } req, err = cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil)