{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/70509747","id":70509747,"diff_hunk":"@@ -0,0 +1,130 @@\n+// +build !windows\n+\n+package main\n+\n+import (\n+\t\"strings\"\n+\t\"time\"\n+\n+\t\"github.com/docker/docker/daemon/cluster/executor/container\"\n+\t\"github.com/docker/docker/pkg/integration/checker\"\n+\t\"github.com/docker/engine-api/types/swarm\"\n+\t\"github.com/go-check/check\"\n+)\n+\n+// start a service, and then make its task unhealthy during running\n+// finally, unhealthy task should be detected and killed\n+func (s *DockerSwarmSuite) TestServiceHealthRun(c *check.C) {\n+\ttestRequires(c, DaemonIsLinux) // busybox doesn't work on Windows\n+\n+\td := s.AddDaemon(c, true, true)\n+\n+\t// build image with health-check\n+\t// note: use `daemon.buildImageWithOut` to build, do not use `buildImage` to build\n+\timageName := \"testhealth\"\n+\t_, _, err := d.buildImageWithOut(imageName,\n+\t\t`FROM busybox\n+\t\tRUN touch /status\n+\t\tHEALTHCHECK --interval=5s --timeout=1s --retries=1\\\n+\t\t  CMD cat /status`,\n+\t\ttrue)\n+\tc.Check(err, check.IsNil)\n+\n+\tserviceName := \"healthServiceRun\"\n+\tout, err := d.Cmd(\"service\", \"create\", \"--name\", serviceName, imageName, \"top\")\n+\tc.Assert(err, checker.IsNil, check.Commentf(out))\n+\tid := strings.TrimSpace(out)\n+\n+\tvar tasks []swarm.Task\n+\twaitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {\n+\t\ttasks = d.getServiceTasks(c, id)\n+\t\treturn len(tasks) > 0, nil\n+\t}, checker.Equals, true)\n+\n+\ttask := tasks[0]\n+\tcontainerName := serviceName + \".1.\" + task.ID\n+\t// wait for container to be healthy\n+\twaitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {\n+\t\tout, _ := d.Cmd(\"inspect\", \"--format={{.State.Health.Status}}\", containerName)\n+\t\treturn out == \"healthy\\n\", nil\n+\t}, checker.Equals, true)","path":"integration-cli/docker_cli_service_health_test.go","position":50,"original_position":50,"commit_id":"8eeb2178b274a4aa374be56ea8e40689675b9b9f","original_commit_id":"8eeb2178b274a4aa374be56ea8e40689675b9b9f","user":{"login":"tonistiigi","id":585223,"avatar_url":"https://avatars.githubusercontent.com/u/585223?v=3","gravatar_id":"","url":"https://api.github.com/users/tonistiigi","html_url":"https://github.com/tonistiigi","followers_url":"https://api.github.com/users/tonistiigi/followers","following_url":"https://api.github.com/users/tonistiigi/following{/other_user}","gists_url":"https://api.github.com/users/tonistiigi/gists{/gist_id}","starred_url":"https://api.github.com/users/tonistiigi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonistiigi/subscriptions","organizations_url":"https://api.github.com/users/tonistiigi/orgs","repos_url":"https://api.github.com/users/tonistiigi/repos","events_url":"https://api.github.com/users/tonistiigi/events{/privacy}","received_events_url":"https://api.github.com/users/tonistiigi/received_events","type":"User","site_admin":false},"body":"```\r\nc.Assert(err, checker.IsNil)\r\nreturn strings.TrimSpace(out), nil\r\n```\r\n`checker.Equals, \"healthy\"`","created_at":"2016-07-12T19:54:34Z","updated_at":"2016-07-12T19:54:34Z","html_url":"https://github.com/docker/docker/pull/24545#discussion_r70509747","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/24545","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/70509747"},"html":{"href":"https://github.com/docker/docker/pull/24545#discussion_r70509747"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/24545"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/24545","id":77166838,"html_url":"https://github.com/docker/docker/pull/24545","diff_url":"https://github.com/docker/docker/pull/24545.diff","patch_url":"https://github.com/docker/docker/pull/24545.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/24545","number":24545,"state":"open","locked":false,"title":"swarm: block controller.Start until container is healthy","user":{"login":"runshenzhu","id":7114218,"avatar_url":"https://avatars.githubusercontent.com/u/7114218?v=3","gravatar_id":"","url":"https://api.github.com/users/runshenzhu","html_url":"https://github.com/runshenzhu","followers_url":"https://api.github.com/users/runshenzhu/followers","following_url":"https://api.github.com/users/runshenzhu/following{/other_user}","gists_url":"https://api.github.com/users/runshenzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/runshenzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runshenzhu/subscriptions","organizations_url":"https://api.github.com/users/runshenzhu/orgs","repos_url":"https://api.github.com/users/runshenzhu/repos","events_url":"https://api.github.com/users/runshenzhu/events{/privacy}","received_events_url":"https://api.github.com/users/runshenzhu/received_events","type":"User","site_admin":false},"body":"This PR extends health check to tasks' starting stage. Tasks will be blocked in starting status, until health check is passed.\r\n\r\nrelated to [docker/swarmkit#1122](https://github.com/docker/swarmkit/pull/1122)\r\n\r\nping @tonistiigi","created_at":"2016-07-12T18:23:10Z","updated_at":"2016-07-12T19:54:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"81b0053cd1e63f96e5aba0d6342671c0e4ffbb71","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/24545/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/24545/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/24545/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/8eeb2178b274a4aa374be56ea8e40689675b9b9f","head":{"label":"runshenzhu:health-check","ref":"health-check","sha":"8eeb2178b274a4aa374be56ea8e40689675b9b9f","user":{"login":"runshenzhu","id":7114218,"avatar_url":"https://avatars.githubusercontent.com/u/7114218?v=3","gravatar_id":"","url":"https://api.github.com/users/runshenzhu","html_url":"https://github.com/runshenzhu","followers_url":"https://api.github.com/users/runshenzhu/followers","following_url":"https://api.github.com/users/runshenzhu/following{/other_user}","gists_url":"https://api.github.com/users/runshenzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/runshenzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runshenzhu/subscriptions","organizations_url":"https://api.github.com/users/runshenzhu/orgs","repos_url":"https://api.github.com/users/runshenzhu/repos","events_url":"https://api.github.com/users/runshenzhu/events{/privacy}","received_events_url":"https://api.github.com/users/runshenzhu/received_events","type":"User","site_admin":false},"repo":{"id":62099045,"name":"docker","full_name":"runshenzhu/docker","owner":{"login":"runshenzhu","id":7114218,"avatar_url":"https://avatars.githubusercontent.com/u/7114218?v=3","gravatar_id":"","url":"https://api.github.com/users/runshenzhu","html_url":"https://github.com/runshenzhu","followers_url":"https://api.github.com/users/runshenzhu/followers","following_url":"https://api.github.com/users/runshenzhu/following{/other_user}","gists_url":"https://api.github.com/users/runshenzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/runshenzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runshenzhu/subscriptions","organizations_url":"https://api.github.com/users/runshenzhu/orgs","repos_url":"https://api.github.com/users/runshenzhu/repos","events_url":"https://api.github.com/users/runshenzhu/events{/privacy}","received_events_url":"https://api.github.com/users/runshenzhu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/runshenzhu/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/runshenzhu/docker","forks_url":"https://api.github.com/repos/runshenzhu/docker/forks","keys_url":"https://api.github.com/repos/runshenzhu/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runshenzhu/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runshenzhu/docker/teams","hooks_url":"https://api.github.com/repos/runshenzhu/docker/hooks","issue_events_url":"https://api.github.com/repos/runshenzhu/docker/issues/events{/number}","events_url":"https://api.github.com/repos/runshenzhu/docker/events","assignees_url":"https://api.github.com/repos/runshenzhu/docker/assignees{/user}","branches_url":"https://api.github.com/repos/runshenzhu/docker/branches{/branch}","tags_url":"https://api.github.com/repos/runshenzhu/docker/tags","blobs_url":"https://api.github.com/repos/runshenzhu/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runshenzhu/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runshenzhu/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/runshenzhu/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runshenzhu/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/runshenzhu/docker/languages","stargazers_url":"https://api.github.com/repos/runshenzhu/docker/stargazers","contributors_url":"https://api.github.com/repos/runshenzhu/docker/contributors","subscribers_url":"https://api.github.com/repos/runshenzhu/docker/subscribers","subscription_url":"https://api.github.com/repos/runshenzhu/docker/subscription","commits_url":"https://api.github.com/repos/runshenzhu/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/runshenzhu/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/runshenzhu/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/runshenzhu/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/runshenzhu/docker/contents/{+path}","compare_url":"https://api.github.com/repos/runshenzhu/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runshenzhu/docker/merges","archive_url":"https://api.github.com/repos/runshenzhu/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runshenzhu/docker/downloads","issues_url":"https://api.github.com/repos/runshenzhu/docker/issues{/number}","pulls_url":"https://api.github.com/repos/runshenzhu/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/runshenzhu/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/runshenzhu/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runshenzhu/docker/labels{/name}","releases_url":"https://api.github.com/repos/runshenzhu/docker/releases{/id}","deployments_url":"https://api.github.com/repos/runshenzhu/docker/deployments","created_at":"2016-06-28T01:07:59Z","updated_at":"2016-06-28T01:08:13Z","pushed_at":"2016-07-12T18:28:17Z","git_url":"git://github.com/runshenzhu/docker.git","ssh_url":"git@github.com:runshenzhu/docker.git","clone_url":"https://github.com/runshenzhu/docker.git","svn_url":"https://github.com/runshenzhu/docker","homepage":"http://www.docker.com","size":98729,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"a44f0107023aa62d202b068c0a8d4b5ad0640838","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-07-12T19:14:04Z","pushed_at":"2016-07-12T19:52:50Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":204564,"stargazers_count":32921,"watchers_count":32921,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9522,"mirror_url":null,"open_issues_count":1960,"forks":9522,"open_issues":1960,"watchers":32921,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/24545"},"html":{"href":"https://github.com/docker/docker/pull/24545"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/24545"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/24545/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/24545/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/24545/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/8eeb2178b274a4aa374be56ea8e40689675b9b9f"}}}}
{"actor":{"display_login":"tonistiigi"}}