Skip to content
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

Merged
merged 1 commit into from
Aug 7, 2015

Conversation

cpuguy83
Copy link
Member

@cpuguy83 cpuguy83 commented Aug 6, 2015

Closes #15309

@@ -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?")
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about errConnectionFailed

Copy link
Member Author

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.

@cpuguy83 cpuguy83 force-pushed the better_error_on_client_connect branch from 3d999e1 to 337f1de Compare August 6, 2015 17:12
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") {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good call

Copy link
Member Author

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.

@cpuguy83 cpuguy83 force-pushed the better_error_on_client_connect branch 2 times, most recently from 381c26e to d630217 Compare August 6, 2015 19:00
@cpuguy83
Copy link
Member Author

cpuguy83 commented Aug 6, 2015

@aaronlehmann This is updated.

@duglin
Copy link
Contributor

duglin commented Aug 6, 2015

LGTM

Closes moby#15309

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the better_error_on_client_connect branch from d630217 to 9994a35 Compare August 6, 2015 20:42
@aaronlehmann
Copy link
Contributor

LGTM

@calavera
Copy link
Contributor

calavera commented Aug 7, 2015

nice. LGTM!

calavera added a commit that referenced this pull request Aug 7, 2015
Better/more specific error messages on connect
@calavera calavera merged commit 0262d40 into moby:master Aug 7, 2015
@cpuguy83 cpuguy83 deleted the better_error_on_client_connect branch August 7, 2015 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants