{"action":"created","comment":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/45657322","id":45657322,"diff_hunk":"@@ -112,6 +112,32 @@ def loop(result):\n     return d.addActionFinish()\n \n \n+def timeout(reactor, deferred, timeout_sec):\n+    \"\"\"Adds a timeout to an existing deferred. If the timeout expires before\n+    the deferred expires, then the deferred is cancelled.\n+\n+    :param reactor: The reactor implementation to schedule the timeout.\n+    :type reactor: ``IReactorTime``.\n+\n+    :param deferred: The deferred to cancel at a later point in time.\n+    :type deferred: ``Deferred``.\n+\n+    :param timeout_sec: The number of seconds to wait before the deferred\n+                        should time out.\n+    :type timeout_sec: ``float``.","path":"flocker/common/_retry.py","position":16,"original_position":16,"commit_id":"52a040bfbb0384818704f2b38484864dd012b669","original_commit_id":"52a040bfbb0384818704f2b38484864dd012b669","user":{"login":"sarum90","id":604129,"avatar_url":"https://avatars.githubusercontent.com/u/604129?v=3","gravatar_id":"","url":"https://api.github.com/users/sarum90","html_url":"https://github.com/sarum90","followers_url":"https://api.github.com/users/sarum90/followers","following_url":"https://api.github.com/users/sarum90/following{/other_user}","gists_url":"https://api.github.com/users/sarum90/gists{/gist_id}","starred_url":"https://api.github.com/users/sarum90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarum90/subscriptions","organizations_url":"https://api.github.com/users/sarum90/orgs","repos_url":"https://api.github.com/users/sarum90/repos","events_url":"https://api.github.com/users/sarum90/events{/privacy}","received_events_url":"https://api.github.com/users/sarum90/received_events","type":"User","site_admin":false},"body":"Done, Agreed.\r\n\r\n(I was trying to mimic the documentation for \"loop_until\")","created_at":"2015-11-23T20:39:42Z","updated_at":"2015-11-23T20:39:42Z","html_url":"https://github.com/ClusterHQ/flocker/pull/2203#discussion_r45657322","pull_request_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203","_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/45657322"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/2203#discussion_r45657322"},"pull_request":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203"}}},"pull_request":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203","id":51311525,"html_url":"https://github.com/ClusterHQ/flocker/pull/2203","diff_url":"https://github.com/ClusterHQ/flocker/pull/2203.diff","patch_url":"https://github.com/ClusterHQ/flocker/pull/2203.patch","issue_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/2203","number":2203,"state":"open","locked":false,"title":"[FLOC-3465] Improve poll length and add flongle timeout.","user":{"login":"sarum90","id":604129,"avatar_url":"https://avatars.githubusercontent.com/u/604129?v=3","gravatar_id":"","url":"https://api.github.com/users/sarum90","html_url":"https://github.com/sarum90","followers_url":"https://api.github.com/users/sarum90/followers","following_url":"https://api.github.com/users/sarum90/following{/other_user}","gists_url":"https://api.github.com/users/sarum90/gists{/gist_id}","starred_url":"https://api.github.com/users/sarum90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarum90/subscriptions","organizations_url":"https://api.github.com/users/sarum90/orgs","repos_url":"https://api.github.com/users/sarum90/repos","events_url":"https://api.github.com/users/sarum90/events{/privacy}","received_events_url":"https://api.github.com/users/sarum90/received_events","type":"User","site_admin":false},"body":"This PR addresses 2 issues:\r\n\r\n- Currently the Flocker plugin for Docker polls the Flocker API way fast (20x a second).\r\n- Currently the Flocker plugin for Docker polls forever waiting for a dataset to be present on its node.\r\n\r\nTo address the first issue I just increased the poll time rather than doing a fancier solution like exponential backoff. It seems to me that without good data on how long convergence normally takes fancier solutions would be premature.\r\n\r\nTo address the second issue I implemented a timeout that cancels the polling deferred after two minutes. When it cancels it returns a dict to Docker that has \"Err\" set to a reasonable error string.\r\n\r\nIt might be tempting to return a non 200/OK response, but by inspecting the current docker code it seems that they will take precisely the string you pass in Err for 200s: https://github.com/docker/docker/blob/877fe61f7538a36c5fe312221356f13b83abbf64/volume/drivers/proxy.go#L120, they even have a test for this API: https://github.com/docker/docker/blob/877fe61f7538a36c5fe312221356f13b83abbf64/volume/drivers/proxy_test.go#L61 and they did not have explicit tests for anything that returned non-200.\r\n\r\nOur tests for the flocker plugin for docker use a loopback networking device which made it slightly difficult to inject a Clock as the reactor for just half of the test. The approach I took was to patch the Klein endpoint execution to inject fake clock advancement after the endpoint was run.\r\n\r\nMy door is open for ways to actually test this in combination with a running instance of docker. It'd be nice to gain some confidence that this response works as expected.\r\n\r\nManually ran docker with a hacked up version of the code to force a timeout:\r\n\r\n```\r\nroot@ip-172-31-25-58:~# docker run -it -v cat:/data --volume-driver flocker busybox /bin/sh\r\nError response from daemon: Cannot start container e8d68324dd5de31f267faa23c9d42736760106c930eb53685a1651757e796318: Timed out waiting for dataset to mount.\r\n```","created_at":"2015-11-20T02:43:45Z","updated_at":"2015-11-23T20:39:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f06e6baa25ec728d6a5e84b7472a7ff963e90c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203/commits","review_comments_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203/comments","review_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/2203/comments","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/52a040bfbb0384818704f2b38484864dd012b669","head":{"label":"ClusterHQ:improve-poll-length-and-add-flongle-timeout-FLOC-3465","ref":"improve-poll-length-and-add-flongle-timeout-FLOC-3465","sha":"52a040bfbb0384818704f2b38484864dd012b669","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Container data volume manager for your Dockerized application","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-11-23T12:07:23Z","pushed_at":"2015-11-23T20:33:45Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":44815,"stargazers_count":1965,"watchers_count":1965,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":142,"mirror_url":null,"open_issues_count":33,"forks":142,"open_issues":33,"watchers":1965,"default_branch":"master"}},"base":{"label":"ClusterHQ:master","ref":"master","sha":"791b683d32f52b8c02c1ada66cf7264b53b478ab","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Container data volume manager for your Dockerized application","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-11-23T12:07:23Z","pushed_at":"2015-11-23T20:33:45Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":44815,"stargazers_count":1965,"watchers_count":1965,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":142,"mirror_url":null,"open_issues_count":33,"forks":142,"open_issues":33,"watchers":1965,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/2203"},"issue":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/2203"},"comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/2203/comments"},"review_comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203/comments"},"review_comment":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/2203/commits"},"statuses":{"href":"https://api.github.com/repos/ClusterHQ/flocker/statuses/52a040bfbb0384818704f2b38484864dd012b669"}}}}