-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better/more specific error messages on connect #15370
Conversation
@@ -30,7 +30,7 @@ import ( | |||
) | |||
|
|||
var ( | |||
errConnectionRefused = errors.New("Cannot connect to the Docker daemon. Is 'docker -d' running on this host?") | |||
errConnectionRefused = errors.New("Cannot connect to the Docker daemon. Is the docker daemon running on this host?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm being pedantic, but maybe it's better to call this errConnectionFailed
. Since this error is also returned in a timeout condition, it doesn't necessarily indicate a refusal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I couldn't think of a good name to change it to... I don't think errConnectionFailed is a good name either unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about errConnectionFailed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I can't think of something better.
3d999e1
to
337f1de
Compare
if err != nil { | ||
if strings.Contains(err.Error(), "connection refused") { | ||
return serverResp, errConnectionRefused | ||
if strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") || strings.Contains(err.Error(), "i/o timeout") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more robust way to check for a timeout would be to attempt a type assertion to net.Error
, and then call the Timeout
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, if something creates a new error using the text from the original net.Error
, this wouldn't work. So we'd need to make sure we'd actually see a net.Error
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't have any problem with that. People shouldn't be shadowing the errors, and this is coming straight from the net conn.
381c26e
to
d630217
Compare
@aaronlehmann This is updated. |
LGTM |
Closes moby#15309 Signed-off-by: Brian Goff <cpuguy83@gmail.com>
d630217
to
9994a35
Compare
LGTM |
nice. LGTM! |
Better/more specific error messages on connect
Closes #15309