{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/20355","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/20355/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/20355/comments","events_url":"https://api.github.com/repos/docker/docker/issues/20355/events","html_url":"https://github.com/docker/docker/pull/20355","id":134006463,"number":20355,"title":"Refactor Container State","user":{"login":"WeiZhang555","id":1203611,"avatar_url":"https://avatars.githubusercontent.com/u/1203611?v=3","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/group/windows","name":"group/windows","color":"F6FBFF"},{"url":"https://api.github.com/repos/docker/docker/labels/status/0-triage","name":"status/0-triage","color":"EEEEEE"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-02-16T15:12:23Z","updated_at":"2016-02-16T16:57:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/20355","html_url":"https://github.com/docker/docker/pull/20355","diff_url":"https://github.com/docker/docker/pull/20355.diff","patch_url":"https://github.com/docker/docker/pull/20355.patch"},"body":"Using enum value format to represent container's state as:\r\n```\r\ntype Cstate int64\r\nconst (\r\n    Stopped Cstate = 0\r\n    Running Cstate = (1 << iota)\r\n    Paused\r\n    Restarting\r\n    RemovalInProgress\r\n    Dead\r\n)\r\n```\r\n\r\nso as to replace redundant bool values such as `Running, Paused bool`\r\n\r\nCurrently we have some places didn't handle state `restarting` right,  which is caused by confused container state from my point of view. . `IsRunning()` includes `IsPaused()` and `IsRestarting()`, this is ridiculous and I guess this is for easier code implementation before.\r\n\r\nThis PR will end this design, it will confine container in a single and precise state, a container can only be either running or restarting but can't be both at the same time, it will make code more clear, and easier to control.\r\n\r\nAs `docker inspect` makes use of the container state, I have done some translation in code so it **WON'T** break backward compatibility.\r\n\r\nUnfinished:\r\n-[] Fix test cases.\r\n-[] Check whether expecting container `state` is right what we really want.\r\n-[] Clean some unused daemon error, maybe throw same error `ErrorCodeInvalidState` instead of specific error for each.\r\n\r\n*This is a initial commit for showing the design*\r\n\r\nSigned-off-by: Zhang Wei <zhangwei555@huawei.com>"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/184769448","html_url":"https://github.com/docker/docker/pull/20355#issuecomment-184769448","issue_url":"https://api.github.com/repos/docker/docker/issues/20355","id":184769448,"user":{"login":"GordonTheTurtle","id":10620046,"avatar_url":"https://avatars.githubusercontent.com/u/10620046?v=3","gravatar_id":"","url":"https://api.github.com/users/GordonTheTurtle","html_url":"https://github.com/GordonTheTurtle","followers_url":"https://api.github.com/users/GordonTheTurtle/followers","following_url":"https://api.github.com/users/GordonTheTurtle/following{/other_user}","gists_url":"https://api.github.com/users/GordonTheTurtle/gists{/gist_id}","starred_url":"https://api.github.com/users/GordonTheTurtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GordonTheTurtle/subscriptions","organizations_url":"https://api.github.com/users/GordonTheTurtle/orgs","repos_url":"https://api.github.com/users/GordonTheTurtle/repos","events_url":"https://api.github.com/users/GordonTheTurtle/events{/privacy}","received_events_url":"https://api.github.com/users/GordonTheTurtle/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T16:57:42Z","updated_at":"2016-02-16T16:57:42Z","body":"Job: Docker-PRs-Win2Lin [FAILED](https://jenkins.dockerproject.org/job/Docker-PRs-Win2Lin/21794/console):\n\n~~~console\n\n---\n.317s\nPASS: docker_api_network_test.go:122: DockerSuite.TestApiNetworkConnectDisconnect\t1.396s\nPASS: docker_api_network_test.go:43: DockerSuite.TestApiNetworkCreateCheckDuplicate\t0.550s\nPASS: docker_api_network_test.go:27: DockerSuite.TestApiNetworkCreateDelete\t0.472s\nPASS: docker_api_network_test.go:66: DockerSuite.TestApiNetworkFilter\t0.005s\nPASS: docker_api_network_test.go:18: DockerSuite.TestApiNetworkGetDefaults\t0.010s\n\n----------------------------------------------------------------------\nFAIL: docker_api_network_test.go:72: DockerSuite.TestApiNetworkInspect\n\ndocker_api_network_test.go:79:\n    // run a container and attach it to the default bridge network\n    out, _ := dockerCmd(c, \"run\", \"-d\", \"--name\", \"test\", \"busybox\", \"top\")\nC:/Jenkins/gopath/src/github.com/docker/docker/pkg/integration/dockerCmd_utils.go:42:\n    c.Assert(err, check.IsNil, check.Commentf(quote+\"%v\"+quote+\" failed with errors: %s, %v\", strings.Join(args, \" \"), out, err))\n... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc08216a320)} (\"exit status 125\"\n---\n\n~~~"}}