{"action":"created","comment":{"url":"https://api.github.com/repos/juju/amulet/pulls/comments/28718797","id":28718797,"diff_hunk":"@@ -254,24 +261,26 @@ def wait_for_status(self, juju_env, services, timeout=300):\n             raise\n \n     def wait(self, timeout=300):\n-        #for unit in self.unit:\n         ready = False\n         try:\n             with helpers.timeout(timeout):\n                 # Make sure we're in a 'started' state across the board\n-                waiter.wait(timeout=timeout)\n-                while not ready:\n+                now = time.time()\n+                while not ready and now + timeout < time.time():\n+                    waiter.wait(timeout=15)\n                     for unit in self.unit.keys():\n-                        status = self.unit[unit].juju_agent()\n-                        # Check if we have a hook key and it's not None\n-                        if status is None:\n-                            ready = False\n-                            break\n-                        if 'hook' in status and status['hook']:\n-                            ready = False\n-                            break\n-                        else:\n-                            ready = True\n+                        if unit['agent-state'] == 'started':\n+                            status = self.unit[unit].juju_agent()\n+\n+                            # Check if we have a hook key and it's not None\n+                            if status is None:\n+                                ready = False\n+                                break\n+                            if 'hook' in status and status['hook']:","path":"amulet/sentry.py","position":71,"original_position":71,"commit_id":"dcb0483bb70645e0f264cf673e9feb2d6ec95b36","original_commit_id":"dcb0483bb70645e0f264cf673e9feb2d6ec95b36","user":{"login":"AdamIsrael","id":125008,"avatar_url":"https://avatars.githubusercontent.com/u/125008?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamIsrael","html_url":"https://github.com/AdamIsrael","followers_url":"https://api.github.com/users/AdamIsrael/followers","following_url":"https://api.github.com/users/AdamIsrael/following{/other_user}","gists_url":"https://api.github.com/users/AdamIsrael/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamIsrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamIsrael/subscriptions","organizations_url":"https://api.github.com/users/AdamIsrael/orgs","repos_url":"https://api.github.com/users/AdamIsrael/repos","events_url":"https://api.github.com/users/AdamIsrael/events{/privacy}","received_events_url":"https://api.github.com/users/AdamIsrael/received_events","type":"User","site_admin":false},"body":"If you mean the 'hook' in status, that was existing. I'm not exactly sure what the use case for it is, so I left it as is.","created_at":"2015-04-20T19:07:22Z","updated_at":"2015-04-20T19:07:22Z","html_url":"https://github.com/juju/amulet/pull/67#discussion_r28718797","pull_request_url":"https://api.github.com/repos/juju/amulet/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/juju/amulet/pulls/comments/28718797"},"html":{"href":"https://github.com/juju/amulet/pull/67#discussion_r28718797"},"pull_request":{"href":"https://api.github.com/repos/juju/amulet/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/juju/amulet/pulls/67","id":32967140,"html_url":"https://github.com/juju/amulet/pull/67","diff_url":"https://github.com/juju/amulet/pull/67.diff","patch_url":"https://github.com/juju/amulet/pull/67.patch","issue_url":"https://api.github.com/repos/juju/amulet/issues/67","number":67,"state":"open","locked":false,"title":"Fix wait() logic wrt timeout","user":{"login":"AdamIsrael","id":125008,"avatar_url":"https://avatars.githubusercontent.com/u/125008?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamIsrael","html_url":"https://github.com/AdamIsrael","followers_url":"https://api.github.com/users/AdamIsrael/followers","following_url":"https://api.github.com/users/AdamIsrael/following{/other_user}","gists_url":"https://api.github.com/users/AdamIsrael/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamIsrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamIsrael/subscriptions","organizations_url":"https://api.github.com/users/AdamIsrael/orgs","repos_url":"https://api.github.com/users/AdamIsrael/repos","events_url":"https://api.github.com/users/AdamIsrael/events{/privacy}","received_events_url":"https://api.github.com/users/AdamIsrael/received_events","type":"User","site_admin":false},"body":"This PR addresses lp:1430488. \r\n\r\nThe `waiter.wait` blocks for the full duration of the timeout, and `helpers.timeout` creates a signal-based timeout that's triggered when the timeout expires. This lead to `juju_agent()` being run against a unit still installing, which would throw an exception.\r\n\r\nI made `waiter.wait` block for a smaller, arbitrary value of time (15 seconds), check the unit status, and repeat until it's ready or the timeout is expired.","created_at":"2015-04-09T15:32:51Z","updated_at":"2015-04-20T19:07:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a73292692016c8141a62f91e1ac543ccfdf60d13","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/juju/amulet/pulls/67/commits","review_comments_url":"https://api.github.com/repos/juju/amulet/pulls/67/comments","review_comment_url":"https://api.github.com/repos/juju/amulet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/juju/amulet/issues/67/comments","statuses_url":"https://api.github.com/repos/juju/amulet/statuses/dcb0483bb70645e0f264cf673e9feb2d6ec95b36","head":{"label":"AdamIsrael:lp-1430488","ref":"lp-1430488","sha":"dcb0483bb70645e0f264cf673e9feb2d6ec95b36","user":{"login":"AdamIsrael","id":125008,"avatar_url":"https://avatars.githubusercontent.com/u/125008?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamIsrael","html_url":"https://github.com/AdamIsrael","followers_url":"https://api.github.com/users/AdamIsrael/followers","following_url":"https://api.github.com/users/AdamIsrael/following{/other_user}","gists_url":"https://api.github.com/users/AdamIsrael/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamIsrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamIsrael/subscriptions","organizations_url":"https://api.github.com/users/AdamIsrael/orgs","repos_url":"https://api.github.com/users/AdamIsrael/repos","events_url":"https://api.github.com/users/AdamIsrael/events{/privacy}","received_events_url":"https://api.github.com/users/AdamIsrael/received_events","type":"User","site_admin":false},"repo":{"id":32888884,"name":"amulet","full_name":"AdamIsrael/amulet","owner":{"login":"AdamIsrael","id":125008,"avatar_url":"https://avatars.githubusercontent.com/u/125008?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamIsrael","html_url":"https://github.com/AdamIsrael","followers_url":"https://api.github.com/users/AdamIsrael/followers","following_url":"https://api.github.com/users/AdamIsrael/following{/other_user}","gists_url":"https://api.github.com/users/AdamIsrael/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamIsrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamIsrael/subscriptions","organizations_url":"https://api.github.com/users/AdamIsrael/orgs","repos_url":"https://api.github.com/users/AdamIsrael/repos","events_url":"https://api.github.com/users/AdamIsrael/events{/privacy}","received_events_url":"https://api.github.com/users/AdamIsrael/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AdamIsrael/amulet","description":"Testing harness and tools for Juju Charms","fork":true,"url":"https://api.github.com/repos/AdamIsrael/amulet","forks_url":"https://api.github.com/repos/AdamIsrael/amulet/forks","keys_url":"https://api.github.com/repos/AdamIsrael/amulet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AdamIsrael/amulet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AdamIsrael/amulet/teams","hooks_url":"https://api.github.com/repos/AdamIsrael/amulet/hooks","issue_events_url":"https://api.github.com/repos/AdamIsrael/amulet/issues/events{/number}","events_url":"https://api.github.com/repos/AdamIsrael/amulet/events","assignees_url":"https://api.github.com/repos/AdamIsrael/amulet/assignees{/user}","branches_url":"https://api.github.com/repos/AdamIsrael/amulet/branches{/branch}","tags_url":"https://api.github.com/repos/AdamIsrael/amulet/tags","blobs_url":"https://api.github.com/repos/AdamIsrael/amulet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AdamIsrael/amulet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AdamIsrael/amulet/git/refs{/sha}","trees_url":"https://api.github.com/repos/AdamIsrael/amulet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AdamIsrael/amulet/statuses/{sha}","languages_url":"https://api.github.com/repos/AdamIsrael/amulet/languages","stargazers_url":"https://api.github.com/repos/AdamIsrael/amulet/stargazers","contributors_url":"https://api.github.com/repos/AdamIsrael/amulet/contributors","subscribers_url":"https://api.github.com/repos/AdamIsrael/amulet/subscribers","subscription_url":"https://api.github.com/repos/AdamIsrael/amulet/subscription","commits_url":"https://api.github.com/repos/AdamIsrael/amulet/commits{/sha}","git_commits_url":"https://api.github.com/repos/AdamIsrael/amulet/git/commits{/sha}","comments_url":"https://api.github.com/repos/AdamIsrael/amulet/comments{/number}","issue_comment_url":"https://api.github.com/repos/AdamIsrael/amulet/issues/comments{/number}","contents_url":"https://api.github.com/repos/AdamIsrael/amulet/contents/{+path}","compare_url":"https://api.github.com/repos/AdamIsrael/amulet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AdamIsrael/amulet/merges","archive_url":"https://api.github.com/repos/AdamIsrael/amulet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AdamIsrael/amulet/downloads","issues_url":"https://api.github.com/repos/AdamIsrael/amulet/issues{/number}","pulls_url":"https://api.github.com/repos/AdamIsrael/amulet/pulls{/number}","milestones_url":"https://api.github.com/repos/AdamIsrael/amulet/milestones{/number}","notifications_url":"https://api.github.com/repos/AdamIsrael/amulet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AdamIsrael/amulet/labels{/name}","releases_url":"https://api.github.com/repos/AdamIsrael/amulet/releases{/id}","created_at":"2015-03-25T20:26:10Z","updated_at":"2015-04-02T15:46:20Z","pushed_at":"2015-04-17T19:33:01Z","git_url":"git://github.com/AdamIsrael/amulet.git","ssh_url":"git@github.com:AdamIsrael/amulet.git","clone_url":"https://github.com/AdamIsrael/amulet.git","svn_url":"https://github.com/AdamIsrael/amulet","homepage":null,"size":413,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"juju:lp-1430488","ref":"lp-1430488","sha":"4c0ed0d712236d3a7a2ed6eb2af8d76d1724f029","user":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"repo":{"id":11258943,"name":"amulet","full_name":"juju/amulet","owner":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juju/amulet","description":"Testing harness and tools for Juju Charms","fork":false,"url":"https://api.github.com/repos/juju/amulet","forks_url":"https://api.github.com/repos/juju/amulet/forks","keys_url":"https://api.github.com/repos/juju/amulet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juju/amulet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juju/amulet/teams","hooks_url":"https://api.github.com/repos/juju/amulet/hooks","issue_events_url":"https://api.github.com/repos/juju/amulet/issues/events{/number}","events_url":"https://api.github.com/repos/juju/amulet/events","assignees_url":"https://api.github.com/repos/juju/amulet/assignees{/user}","branches_url":"https://api.github.com/repos/juju/amulet/branches{/branch}","tags_url":"https://api.github.com/repos/juju/amulet/tags","blobs_url":"https://api.github.com/repos/juju/amulet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juju/amulet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juju/amulet/git/refs{/sha}","trees_url":"https://api.github.com/repos/juju/amulet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juju/amulet/statuses/{sha}","languages_url":"https://api.github.com/repos/juju/amulet/languages","stargazers_url":"https://api.github.com/repos/juju/amulet/stargazers","contributors_url":"https://api.github.com/repos/juju/amulet/contributors","subscribers_url":"https://api.github.com/repos/juju/amulet/subscribers","subscription_url":"https://api.github.com/repos/juju/amulet/subscription","commits_url":"https://api.github.com/repos/juju/amulet/commits{/sha}","git_commits_url":"https://api.github.com/repos/juju/amulet/git/commits{/sha}","comments_url":"https://api.github.com/repos/juju/amulet/comments{/number}","issue_comment_url":"https://api.github.com/repos/juju/amulet/issues/comments{/number}","contents_url":"https://api.github.com/repos/juju/amulet/contents/{+path}","compare_url":"https://api.github.com/repos/juju/amulet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juju/amulet/merges","archive_url":"https://api.github.com/repos/juju/amulet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juju/amulet/downloads","issues_url":"https://api.github.com/repos/juju/amulet/issues{/number}","pulls_url":"https://api.github.com/repos/juju/amulet/pulls{/number}","milestones_url":"https://api.github.com/repos/juju/amulet/milestones{/number}","notifications_url":"https://api.github.com/repos/juju/amulet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juju/amulet/labels{/name}","releases_url":"https://api.github.com/repos/juju/amulet/releases{/id}","created_at":"2013-07-08T16:13:00Z","updated_at":"2015-03-30T04:20:48Z","pushed_at":"2015-04-17T19:33:02Z","git_url":"git://github.com/juju/amulet.git","ssh_url":"git@github.com:juju/amulet.git","clone_url":"https://github.com/juju/amulet.git","svn_url":"https://github.com/juju/amulet","homepage":null,"size":1323,"stargazers_count":11,"watchers_count":11,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":11,"forks":19,"open_issues":11,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/juju/amulet/pulls/67"},"html":{"href":"https://github.com/juju/amulet/pull/67"},"issue":{"href":"https://api.github.com/repos/juju/amulet/issues/67"},"comments":{"href":"https://api.github.com/repos/juju/amulet/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/juju/amulet/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/juju/amulet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/juju/amulet/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/juju/amulet/statuses/dcb0483bb70645e0f264cf673e9feb2d6ec95b36"}}}}