{"action":"created","comment":{"url":"https://api.github.com/repos/flynn/flynn/pulls/comments/38670074","id":38670074,"diff_hunk":"@@ -290,3 +297,95 @@ func (s *HostSuite) TestResourceLimits(t *c.C) {\n \n \tassertResourceLimits(t, out.String())\n }\n+\n+func (s *HostSuite) TestUpdate(t *c.C) {\n+\tdir := t.MkDir()\n+\tflynnHost := filepath.Join(dir, \"flynn-host\")\n+\trun(t, osexec.Command(\"cp\", args.FlynnHost, flynnHost))\n+\n+\t// start flynn-host\n+\tid := random.String(8)\n+\tvar out bytes.Buffer\n+\tcmd := osexec.Command(\n+\t\tflynnHost,\n+\t\t\"daemon\",\n+\t\t\"--http-port\", \"11113\",\n+\t\t\"--state\", filepath.Join(dir, \"host-state.bolt\"),\n+\t\t\"--id\", id,\n+\t\t\"--backend\", \"mock\",\n+\t\t\"--vol-provider\", \"mock\",\n+\t\t\"--volpath\", filepath.Join(dir, \"volumes\"),\n+\t)\n+\tcmd.Stdout = &out\n+\tcmd.Stderr = &out\n+\tdefer func() {\n+\t\tdebug(t, \"*** flynn-host output ***\")\n+\t\tdebug(t, out.String())\n+\t\tdebug(t, \"*************************\")\n+\t}()\n+\tt.Assert(cmd.Start(), c.IsNil)\n+\tdefer cmd.Process.Kill()\n+\n+\thttpClient := &http.Client{Transport: &http.Transport{Dial: dialer.Retry.Dial}}\n+\tclient := cluster.NewHost(id, \"http://127.0.0.1:11113\", httpClient)\n+\n+\t// exec a program which exits straight away\n+\t_, err := client.Update(\"/bin/true\")\n+\tt.Assert(err, c.NotNil)\n+\tstatus, err := client.GetStatus()\n+\tt.Assert(err, c.IsNil)\n+\tt.Assert(status.ID, c.Equals, id)\n+\tt.Assert(status.PID, c.Equals, cmd.Process.Pid)\n+\n+\t// exec a program which reads the control socket but then exits\n+\t_, err = client.Update(\"/bin/bash\", \"-c\", \"<&4; exit\")\n+\tt.Assert(err, c.NotNil)\n+\tstatus, err = client.GetStatus()\n+\tt.Assert(err, c.IsNil)\n+\tt.Assert(status.ID, c.Equals, id)\n+\tt.Assert(status.PID, c.Equals, cmd.Process.Pid)\n+\n+\t// exec flynn-host and check we get the status from the new daemon\n+\tpid, err := client.Update(\n+\t\tflynnHost,\n+\t\t\"daemon\",\n+\t\t\"--http-port\", \"11113\",\n+\t\t\"--state\", filepath.Join(dir, \"host-state.bolt\"),\n+\t\t\"--id\", id,\n+\t\t\"--backend\", \"mock\",\n+\t\t\"--vol-provider\", \"mock\",\n+\t\t\"--volpath\", filepath.Join(dir, \"volumes\"),\n+\t)\n+\tt.Assert(err, c.IsNil)\n+\tdefer syscall.Kill(pid, syscall.SIGKILL)\n+\n+\tdone := make(chan struct{})\n+\tgo func() {\n+\t\tcmd.Process.Signal(syscall.SIGTERM)\n+\t\tsyscall.Wait4(cmd.Process.Pid, nil, 0, nil)\n+\t\tclose(done)\n+\t}()\n+\tselect {\n+\tcase <-done:\n+\tcase <-time.After(15 * time.Second):\n+\t\tt.Fatal(\"timed out waiting for flynn-host daemon to exit\")\n+\t}\n+\n+\t// client.GetStatus intermittently returns io.EOF right after the update. We","path":"test/test_host.go","position":108,"original_position":108,"commit_id":"ce0190a2e96bb36d1a3707fb41d9b54cf02ce36c","original_commit_id":"41294b2f7e8f6f95281f099f12a41da1a32621b8","user":{"login":"lmars","id":488515,"avatar_url":"https://avatars.githubusercontent.com/u/488515?v=3","gravatar_id":"","url":"https://api.github.com/users/lmars","html_url":"https://github.com/lmars","followers_url":"https://api.github.com/users/lmars/followers","following_url":"https://api.github.com/users/lmars/following{/other_user}","gists_url":"https://api.github.com/users/lmars/gists{/gist_id}","starred_url":"https://api.github.com/users/lmars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmars/subscriptions","organizations_url":"https://api.github.com/users/lmars/orgs","repos_url":"https://api.github.com/users/lmars/repos","events_url":"https://api.github.com/users/lmars/events{/privacy}","received_events_url":"https://api.github.com/users/lmars/received_events","type":"User","site_admin":false},"body":"By this point, the old daemon should not be accepting requests, so this request should be accepted by the new daemon. Are you claiming that the old process may still be accepting requests after the update has finished?","created_at":"2015-09-03T17:11:12Z","updated_at":"2015-09-03T17:11:12Z","html_url":"https://github.com/flynn/flynn/pull/1672#discussion_r38670074","pull_request_url":"https://api.github.com/repos/flynn/flynn/pulls/1672","_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments/38670074"},"html":{"href":"https://github.com/flynn/flynn/pull/1672#discussion_r38670074"},"pull_request":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1672"}}},"pull_request":{"url":"https://api.github.com/repos/flynn/flynn/pulls/1672","id":40412243,"html_url":"https://github.com/flynn/flynn/pull/1672","diff_url":"https://github.com/flynn/flynn/pull/1672.diff","patch_url":"https://github.com/flynn/flynn/pull/1672.patch","issue_url":"https://api.github.com/repos/flynn/flynn/issues/1672","number":1672,"state":"open","locked":false,"title":"host: Support zero-downtime updates","user":{"login":"lmars","id":488515,"avatar_url":"https://avatars.githubusercontent.com/u/488515?v=3","gravatar_id":"","url":"https://api.github.com/users/lmars","html_url":"https://github.com/lmars","followers_url":"https://api.github.com/users/lmars/followers","following_url":"https://api.github.com/users/lmars/following{/other_user}","gists_url":"https://api.github.com/users/lmars/gists{/gist_id}","starred_url":"https://api.github.com/users/lmars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmars/subscriptions","organizations_url":"https://api.github.com/users/lmars/orgs","repos_url":"https://api.github.com/users/lmars/repos","events_url":"https://api.github.com/users/lmars/events{/privacy}","received_events_url":"https://api.github.com/users/lmars/received_events","type":"User","site_admin":false},"body":"Opening for early feedback on the approach.\r\n\r\nAll but the last 3 commits are in #1671 so will disappear once that is merged.","created_at":"2015-07-21T00:34:48Z","updated_at":"2015-09-03T17:11:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8ce01cae11cab80f659cdfca9057d55d4277ee0b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flynn/flynn/pulls/1672/commits","review_comments_url":"https://api.github.com/repos/flynn/flynn/pulls/1672/comments","review_comment_url":"https://api.github.com/repos/flynn/flynn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/flynn/flynn/issues/1672/comments","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/ce0190a2e96bb36d1a3707fb41d9b54cf02ce36c","head":{"label":"flynn:update-flynn-host","ref":"update-flynn-host","sha":"ce0190a2e96bb36d1a3707fb41d9b54cf02ce36c","user":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"repo":{"id":11290232,"name":"flynn","full_name":"flynn/flynn","owner":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flynn/flynn","description":"A next generation open source platform as a service (PaaS)","fork":false,"url":"https://api.github.com/repos/flynn/flynn","forks_url":"https://api.github.com/repos/flynn/flynn/forks","keys_url":"https://api.github.com/repos/flynn/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flynn/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flynn/flynn/teams","hooks_url":"https://api.github.com/repos/flynn/flynn/hooks","issue_events_url":"https://api.github.com/repos/flynn/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/flynn/flynn/events","assignees_url":"https://api.github.com/repos/flynn/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/flynn/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/flynn/flynn/tags","blobs_url":"https://api.github.com/repos/flynn/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flynn/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flynn/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/flynn/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/flynn/flynn/languages","stargazers_url":"https://api.github.com/repos/flynn/flynn/stargazers","contributors_url":"https://api.github.com/repos/flynn/flynn/contributors","subscribers_url":"https://api.github.com/repos/flynn/flynn/subscribers","subscription_url":"https://api.github.com/repos/flynn/flynn/subscription","commits_url":"https://api.github.com/repos/flynn/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/flynn/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/flynn/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/flynn/flynn/issues/comments{/number}","contents_url":"https://api.github.com/repos/flynn/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/flynn/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flynn/flynn/merges","archive_url":"https://api.github.com/repos/flynn/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flynn/flynn/downloads","issues_url":"https://api.github.com/repos/flynn/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/flynn/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/flynn/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/flynn/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flynn/flynn/labels{/name}","releases_url":"https://api.github.com/repos/flynn/flynn/releases{/id}","created_at":"2013-07-09T18:22:06Z","updated_at":"2015-09-03T16:31:29Z","pushed_at":"2015-09-03T16:40:01Z","git_url":"git://github.com/flynn/flynn.git","ssh_url":"git@github.com:flynn/flynn.git","clone_url":"https://github.com/flynn/flynn.git","svn_url":"https://github.com/flynn/flynn","homepage":"https://flynn.io","size":59822,"stargazers_count":3834,"watchers_count":3834,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":268,"mirror_url":null,"open_issues_count":208,"forks":268,"open_issues":208,"watchers":3834,"default_branch":"master"}},"base":{"label":"flynn:master","ref":"master","sha":"026b0155d3634e3ed3a17930725651168a86a1df","user":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"repo":{"id":11290232,"name":"flynn","full_name":"flynn/flynn","owner":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flynn/flynn","description":"A next generation open source platform as a service (PaaS)","fork":false,"url":"https://api.github.com/repos/flynn/flynn","forks_url":"https://api.github.com/repos/flynn/flynn/forks","keys_url":"https://api.github.com/repos/flynn/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flynn/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flynn/flynn/teams","hooks_url":"https://api.github.com/repos/flynn/flynn/hooks","issue_events_url":"https://api.github.com/repos/flynn/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/flynn/flynn/events","assignees_url":"https://api.github.com/repos/flynn/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/flynn/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/flynn/flynn/tags","blobs_url":"https://api.github.com/repos/flynn/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flynn/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flynn/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/flynn/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/flynn/flynn/languages","stargazers_url":"https://api.github.com/repos/flynn/flynn/stargazers","contributors_url":"https://api.github.com/repos/flynn/flynn/contributors","subscribers_url":"https://api.github.com/repos/flynn/flynn/subscribers","subscription_url":"https://api.github.com/repos/flynn/flynn/subscription","commits_url":"https://api.github.com/repos/flynn/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/flynn/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/flynn/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/flynn/flynn/issues/comments{/number}","contents_url":"https://api.github.com/repos/flynn/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/flynn/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flynn/flynn/merges","archive_url":"https://api.github.com/repos/flynn/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flynn/flynn/downloads","issues_url":"https://api.github.com/repos/flynn/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/flynn/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/flynn/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/flynn/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flynn/flynn/labels{/name}","releases_url":"https://api.github.com/repos/flynn/flynn/releases{/id}","created_at":"2013-07-09T18:22:06Z","updated_at":"2015-09-03T16:31:29Z","pushed_at":"2015-09-03T16:40:01Z","git_url":"git://github.com/flynn/flynn.git","ssh_url":"git@github.com:flynn/flynn.git","clone_url":"https://github.com/flynn/flynn.git","svn_url":"https://github.com/flynn/flynn","homepage":"https://flynn.io","size":59822,"stargazers_count":3834,"watchers_count":3834,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":268,"mirror_url":null,"open_issues_count":208,"forks":268,"open_issues":208,"watchers":3834,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1672"},"html":{"href":"https://github.com/flynn/flynn/pull/1672"},"issue":{"href":"https://api.github.com/repos/flynn/flynn/issues/1672"},"comments":{"href":"https://api.github.com/repos/flynn/flynn/issues/1672/comments"},"review_comments":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1672/comments"},"review_comment":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1672/commits"},"statuses":{"href":"https://api.github.com/repos/flynn/flynn/statuses/ce0190a2e96bb36d1a3707fb41d9b54cf02ce36c"}}}}