{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/28659","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/28659/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/28659/comments","events_url":"https://api.github.com/repos/docker/docker/issues/28659/events","html_url":"https://github.com/docker/docker/pull/28659","id":190709094,"number":28659,"title":"bugfix: incorrect ErrConnectFailed Comparison","user":{"login":"xuzhenglun","id":4017672,"avatar_url":"https://avatars.githubusercontent.com/u/4017672?v=3","gravatar_id":"","url":"https://api.github.com/users/xuzhenglun","html_url":"https://github.com/xuzhenglun","followers_url":"https://api.github.com/users/xuzhenglun/followers","following_url":"https://api.github.com/users/xuzhenglun/following{/other_user}","gists_url":"https://api.github.com/users/xuzhenglun/gists{/gist_id}","starred_url":"https://api.github.com/users/xuzhenglun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuzhenglun/subscriptions","organizations_url":"https://api.github.com/users/xuzhenglun/orgs","repos_url":"https://api.github.com/users/xuzhenglun/repos","events_url":"https://api.github.com/users/xuzhenglun/events{/privacy}","received_events_url":"https://api.github.com/users/xuzhenglun/received_events","type":"User","site_admin":false},"labels":[{"id":234913403,"url":"https://api.github.com/repos/docker/docker/labels/dco/no","name":"dco/no","color":"f7c6c7","default":false},{"id":175374554,"url":"https://api.github.com/repos/docker/docker/labels/status/0-triage","name":"status/0-triage","color":"EEEEEE","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-21T12:56:59Z","updated_at":"2016-11-21T13:04:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/28659","html_url":"https://github.com/docker/docker/pull/28659","diff_url":"https://github.com/docker/docker/pull/28659.diff","patch_url":"https://github.com/docker/docker/pull/28659.patch"},"body":"I found that there is a minimal bug about how docker client determine whether the connection has lost. \r\n\r\n```go\r\nvar ErrConnectionFailed = errors.New(\"Cannot connect to the Docker daemon. Is the docker daemon running on this host?\")\r\n```\r\nclient/errors.go\r\n\r\n```go\r\nfunc getExecExitCode(ctx context.Context, client apiclient.ContainerAPIClient, execID string) (bool, int, error) {\r\n\tresp, err := client.ContainerExecInspect(ctx, execID)\r\n\tif err != nil {\r\n\t\t// If we can't connect, then the daemon probably died.\r\n\t\tif !apiclient.IsErrConnectionFailed(err) {\r\n\t\t\treturn false, -1, err\r\n\t\t}\r\n\t\treturn false, -1, nil\r\n\t}\r\n\r\n\treturn resp.Running, resp.ExitCode, nil\r\n}\r\n```\r\ncli/command/container/exec.go\r\n\r\nIn the code, ```err != apiclient.ErrConnectionFailed``` should always be true. Because ```ErrConnectionFailed``` is a object invoked by ```fmt.Errorf```. and ```fmt.Errorf``` can't invoke two identical object in different place.\r\nIn another word, ```return false, -1, nil``` in 8th line should never be run ever.\r\n\r\n\r\n**- What I did**\r\n\r\n1. create the type called ```errConnectionFailed``` and a function called ```IsErrConnectionFailed``` so that it can be determined correctly. Exactly like how other error do in ```client/errors.go```\r\n\r\n**- How I did it**\r\n\r\n**- How to verify it**\r\n\r\n**- Description for the changelog**\r\n<!--\r\nWrite a short (one line) summary that describes the changes in this\r\npull request for inclusion in the changelog:\r\n-->\r\n\r\nSigned-off-by: xuzhenglun@gmail.com"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/261931985","html_url":"https://github.com/docker/docker/pull/28659#issuecomment-261931985","issue_url":"https://api.github.com/repos/docker/docker/issues/28659","id":261931985,"user":{"login":"thaJeztah","id":1804568,"avatar_url":"https://avatars.githubusercontent.com/u/1804568?v=3","gravatar_id":"","url":"https://api.github.com/users/thaJeztah","html_url":"https://github.com/thaJeztah","followers_url":"https://api.github.com/users/thaJeztah/followers","following_url":"https://api.github.com/users/thaJeztah/following{/other_user}","gists_url":"https://api.github.com/users/thaJeztah/gists{/gist_id}","starred_url":"https://api.github.com/users/thaJeztah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaJeztah/subscriptions","organizations_url":"https://api.github.com/users/thaJeztah/orgs","repos_url":"https://api.github.com/users/thaJeztah/repos","events_url":"https://api.github.com/users/thaJeztah/events{/privacy}","received_events_url":"https://api.github.com/users/thaJeztah/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T13:04:29Z","updated_at":"2016-11-21T13:04:29Z","body":"Thanks! Can you amend, and sign-off your commit?\r\n\r\nI think this fixes https://github.com/docker/docker/issues/26773 ?"}}
{"actor":{"display_login":"thaJeztah"}}