Skip to content

Commit

Permalink
client: do not fallback to GET if HEAD on _ping fail to connect
Browse files Browse the repository at this point in the history
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 docker/cli#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>
  • Loading branch information
Ian Campbell committed May 13, 2019
1 parent 3042254 commit 8c8457b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8c8457b

Please sign in to comment.