{"action":"created","comment":{"url":"https://api.github.com/repos/tellapart/Diamond/pulls/comments/23467780","id":23467780,"diff_hunk":"@@ -56,8 +56,14 @@ def get_hostname(config, method=None):\n                                     stdout=subprocess.PIPE)\n             hostname = proc.communicate()[0].strip()\n             if proc.returncode != 0:\n-                raise subprocess.CalledProcessError(proc.returncode,\n-                                                    config['hostname'])\n+                skip_errors = config.get('hostname_cache_skip_errors')\n+                # If we aren't explicitly skipping errors OR we have no cached\n+                # result, raise an exception.\n+                if not skip_errors or method not in get_hostname.cached_results:\n+                    raise subprocess.CalledProcessError(proc.returncode,\n+                                                        config['hostname'])\n+                else:  # Recycle the previously cached version.\n+                    hostname = get_hostname.cached_results[method][0]","path":"src/diamond/collector.py","position":13,"original_position":13,"commit_id":"456cfb7e94ee72e5d492984db945268f9716f263","original_commit_id":"456cfb7e94ee72e5d492984db945268f9716f263","user":{"login":"ThanosBaskous","id":1161523,"avatar_url":"https://avatars.githubusercontent.com/u/1161523?v=3","gravatar_id":"","url":"https://api.github.com/users/ThanosBaskous","html_url":"https://github.com/ThanosBaskous","followers_url":"https://api.github.com/users/ThanosBaskous/followers","following_url":"https://api.github.com/users/ThanosBaskous/following{/other_user}","gists_url":"https://api.github.com/users/ThanosBaskous/gists{/gist_id}","starred_url":"https://api.github.com/users/ThanosBaskous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThanosBaskous/subscriptions","organizations_url":"https://api.github.com/users/ThanosBaskous/orgs","repos_url":"https://api.github.com/users/ThanosBaskous/repos","events_url":"https://api.github.com/users/ThanosBaskous/events{/privacy}","received_events_url":"https://api.github.com/users/ThanosBaskous/received_events","type":"User","site_admin":false},"body":"I think that you should at least log that this is happening somewhere. I see other diamond code that logs to a 'diamond' logger.\r\n\r\nlog = logging.getLogger('diamond')\r\n\r\nIf this were in another application I'd also suggest recording a metric for it so we can alert if it happens a lot, but I'm not sure how that would work on the diamond \"manager\" layer, especially when what you are doing is configuring how you log metrics in the first place (you don't want that failing).","created_at":"2015-01-23T18:09:25Z","updated_at":"2015-01-23T18:09:25Z","html_url":"https://github.com/tellapart/Diamond/pull/8#discussion_r23467780","pull_request_url":"https://api.github.com/repos/tellapart/Diamond/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/tellapart/Diamond/pulls/comments/23467780"},"html":{"href":"https://github.com/tellapart/Diamond/pull/8#discussion_r23467780"},"pull_request":{"href":"https://api.github.com/repos/tellapart/Diamond/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/tellapart/Diamond/pulls/8","id":27800687,"html_url":"https://github.com/tellapart/Diamond/pull/8","diff_url":"https://github.com/tellapart/Diamond/pull/8.diff","patch_url":"https://github.com/tellapart/Diamond/pull/8.patch","issue_url":"https://api.github.com/repos/tellapart/Diamond/issues/8","number":8,"state":"open","locked":false,"title":"Adding hostname_cache_skip_errors flag for shelling out to get hostname.","user":{"login":"GeorgeSirois","id":4085488,"avatar_url":"https://avatars.githubusercontent.com/u/4085488?v=3","gravatar_id":"","url":"https://api.github.com/users/GeorgeSirois","html_url":"https://github.com/GeorgeSirois","followers_url":"https://api.github.com/users/GeorgeSirois/followers","following_url":"https://api.github.com/users/GeorgeSirois/following{/other_user}","gists_url":"https://api.github.com/users/GeorgeSirois/gists{/gist_id}","starred_url":"https://api.github.com/users/GeorgeSirois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeorgeSirois/subscriptions","organizations_url":"https://api.github.com/users/GeorgeSirois/orgs","repos_url":"https://api.github.com/users/GeorgeSirois/repos","events_url":"https://api.github.com/users/GeorgeSirois/events{/privacy}","received_events_url":"https://api.github.com/users/GeorgeSirois/received_events","type":"User","site_admin":false},"body":"This allows Diamond to gracefully handle situations where the shell command returns an error intermittently.\r\n\r\n@ThanosBaskous @steveniemitz @dmontauk @chuegle ","created_at":"2015-01-21T22:22:34Z","updated_at":"2015-01-23T18:09:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fecb183d4176b968bc00541b923152bff2c802d6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tellapart/Diamond/pulls/8/commits","review_comments_url":"https://api.github.com/repos/tellapart/Diamond/pulls/8/comments","review_comment_url":"https://api.github.com/repos/tellapart/Diamond/pulls/comments/{number}","comments_url":"https://api.github.com/repos/tellapart/Diamond/issues/8/comments","statuses_url":"https://api.github.com/repos/tellapart/Diamond/statuses/456cfb7e94ee72e5d492984db945268f9716f263","head":{"label":"tellapart:graceful-host-lookup-failure-handling","ref":"graceful-host-lookup-failure-handling","sha":"456cfb7e94ee72e5d492984db945268f9716f263","user":{"login":"tellapart","id":342225,"avatar_url":"https://avatars.githubusercontent.com/u/342225?v=3","gravatar_id":"","url":"https://api.github.com/users/tellapart","html_url":"https://github.com/tellapart","followers_url":"https://api.github.com/users/tellapart/followers","following_url":"https://api.github.com/users/tellapart/following{/other_user}","gists_url":"https://api.github.com/users/tellapart/gists{/gist_id}","starred_url":"https://api.github.com/users/tellapart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tellapart/subscriptions","organizations_url":"https://api.github.com/users/tellapart/orgs","repos_url":"https://api.github.com/users/tellapart/repos","events_url":"https://api.github.com/users/tellapart/events{/privacy}","received_events_url":"https://api.github.com/users/tellapart/received_events","type":"Organization","site_admin":false},"repo":{"id":26599316,"name":"Diamond","full_name":"tellapart/Diamond","owner":{"login":"tellapart","id":342225,"avatar_url":"https://avatars.githubusercontent.com/u/342225?v=3","gravatar_id":"","url":"https://api.github.com/users/tellapart","html_url":"https://github.com/tellapart","followers_url":"https://api.github.com/users/tellapart/followers","following_url":"https://api.github.com/users/tellapart/following{/other_user}","gists_url":"https://api.github.com/users/tellapart/gists{/gist_id}","starred_url":"https://api.github.com/users/tellapart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tellapart/subscriptions","organizations_url":"https://api.github.com/users/tellapart/orgs","repos_url":"https://api.github.com/users/tellapart/repos","events_url":"https://api.github.com/users/tellapart/events{/privacy}","received_events_url":"https://api.github.com/users/tellapart/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tellapart/Diamond","description":"","fork":true,"url":"https://api.github.com/repos/tellapart/Diamond","forks_url":"https://api.github.com/repos/tellapart/Diamond/forks","keys_url":"https://api.github.com/repos/tellapart/Diamond/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tellapart/Diamond/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tellapart/Diamond/teams","hooks_url":"https://api.github.com/repos/tellapart/Diamond/hooks","issue_events_url":"https://api.github.com/repos/tellapart/Diamond/issues/events{/number}","events_url":"https://api.github.com/repos/tellapart/Diamond/events","assignees_url":"https://api.github.com/repos/tellapart/Diamond/assignees{/user}","branches_url":"https://api.github.com/repos/tellapart/Diamond/branches{/branch}","tags_url":"https://api.github.com/repos/tellapart/Diamond/tags","blobs_url":"https://api.github.com/repos/tellapart/Diamond/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tellapart/Diamond/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tellapart/Diamond/git/refs{/sha}","trees_url":"https://api.github.com/repos/tellapart/Diamond/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tellapart/Diamond/statuses/{sha}","languages_url":"https://api.github.com/repos/tellapart/Diamond/languages","stargazers_url":"https://api.github.com/repos/tellapart/Diamond/stargazers","contributors_url":"https://api.github.com/repos/tellapart/Diamond/contributors","subscribers_url":"https://api.github.com/repos/tellapart/Diamond/subscribers","subscription_url":"https://api.github.com/repos/tellapart/Diamond/subscription","commits_url":"https://api.github.com/repos/tellapart/Diamond/commits{/sha}","git_commits_url":"https://api.github.com/repos/tellapart/Diamond/git/commits{/sha}","comments_url":"https://api.github.com/repos/tellapart/Diamond/comments{/number}","issue_comment_url":"https://api.github.com/repos/tellapart/Diamond/issues/comments/{number}","contents_url":"https://api.github.com/repos/tellapart/Diamond/contents/{+path}","compare_url":"https://api.github.com/repos/tellapart/Diamond/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tellapart/Diamond/merges","archive_url":"https://api.github.com/repos/tellapart/Diamond/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tellapart/Diamond/downloads","issues_url":"https://api.github.com/repos/tellapart/Diamond/issues{/number}","pulls_url":"https://api.github.com/repos/tellapart/Diamond/pulls{/number}","milestones_url":"https://api.github.com/repos/tellapart/Diamond/milestones{/number}","notifications_url":"https://api.github.com/repos/tellapart/Diamond/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tellapart/Diamond/labels{/name}","releases_url":"https://api.github.com/repos/tellapart/Diamond/releases{/id}","created_at":"2014-11-13T17:30:49Z","updated_at":"2015-01-22T23:01:02Z","pushed_at":"2015-01-21T22:21:32Z","git_url":"git://github.com/tellapart/Diamond.git","ssh_url":"git@github.com:tellapart/Diamond.git","clone_url":"https://github.com/tellapart/Diamond.git","svn_url":"https://github.com/tellapart/Diamond","homepage":"","size":4371,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"tellapart:master","ref":"master","sha":"0e1df73f6b92da89830bd0e89e741da2ba2b2cb4","user":{"login":"tellapart","id":342225,"avatar_url":"https://avatars.githubusercontent.com/u/342225?v=3","gravatar_id":"","url":"https://api.github.com/users/tellapart","html_url":"https://github.com/tellapart","followers_url":"https://api.github.com/users/tellapart/followers","following_url":"https://api.github.com/users/tellapart/following{/other_user}","gists_url":"https://api.github.com/users/tellapart/gists{/gist_id}","starred_url":"https://api.github.com/users/tellapart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tellapart/subscriptions","organizations_url":"https://api.github.com/users/tellapart/orgs","repos_url":"https://api.github.com/users/tellapart/repos","events_url":"https://api.github.com/users/tellapart/events{/privacy}","received_events_url":"https://api.github.com/users/tellapart/received_events","type":"Organization","site_admin":false},"repo":{"id":26599316,"name":"Diamond","full_name":"tellapart/Diamond","owner":{"login":"tellapart","id":342225,"avatar_url":"https://avatars.githubusercontent.com/u/342225?v=3","gravatar_id":"","url":"https://api.github.com/users/tellapart","html_url":"https://github.com/tellapart","followers_url":"https://api.github.com/users/tellapart/followers","following_url":"https://api.github.com/users/tellapart/following{/other_user}","gists_url":"https://api.github.com/users/tellapart/gists{/gist_id}","starred_url":"https://api.github.com/users/tellapart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tellapart/subscriptions","organizations_url":"https://api.github.com/users/tellapart/orgs","repos_url":"https://api.github.com/users/tellapart/repos","events_url":"https://api.github.com/users/tellapart/events{/privacy}","received_events_url":"https://api.github.com/users/tellapart/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tellapart/Diamond","description":"","fork":true,"url":"https://api.github.com/repos/tellapart/Diamond","forks_url":"https://api.github.com/repos/tellapart/Diamond/forks","keys_url":"https://api.github.com/repos/tellapart/Diamond/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tellapart/Diamond/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tellapart/Diamond/teams","hooks_url":"https://api.github.com/repos/tellapart/Diamond/hooks","issue_events_url":"https://api.github.com/repos/tellapart/Diamond/issues/events{/number}","events_url":"https://api.github.com/repos/tellapart/Diamond/events","assignees_url":"https://api.github.com/repos/tellapart/Diamond/assignees{/user}","branches_url":"https://api.github.com/repos/tellapart/Diamond/branches{/branch}","tags_url":"https://api.github.com/repos/tellapart/Diamond/tags","blobs_url":"https://api.github.com/repos/tellapart/Diamond/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tellapart/Diamond/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tellapart/Diamond/git/refs{/sha}","trees_url":"https://api.github.com/repos/tellapart/Diamond/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tellapart/Diamond/statuses/{sha}","languages_url":"https://api.github.com/repos/tellapart/Diamond/languages","stargazers_url":"https://api.github.com/repos/tellapart/Diamond/stargazers","contributors_url":"https://api.github.com/repos/tellapart/Diamond/contributors","subscribers_url":"https://api.github.com/repos/tellapart/Diamond/subscribers","subscription_url":"https://api.github.com/repos/tellapart/Diamond/subscription","commits_url":"https://api.github.com/repos/tellapart/Diamond/commits{/sha}","git_commits_url":"https://api.github.com/repos/tellapart/Diamond/git/commits{/sha}","comments_url":"https://api.github.com/repos/tellapart/Diamond/comments{/number}","issue_comment_url":"https://api.github.com/repos/tellapart/Diamond/issues/comments/{number}","contents_url":"https://api.github.com/repos/tellapart/Diamond/contents/{+path}","compare_url":"https://api.github.com/repos/tellapart/Diamond/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tellapart/Diamond/merges","archive_url":"https://api.github.com/repos/tellapart/Diamond/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tellapart/Diamond/downloads","issues_url":"https://api.github.com/repos/tellapart/Diamond/issues{/number}","pulls_url":"https://api.github.com/repos/tellapart/Diamond/pulls{/number}","milestones_url":"https://api.github.com/repos/tellapart/Diamond/milestones{/number}","notifications_url":"https://api.github.com/repos/tellapart/Diamond/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tellapart/Diamond/labels{/name}","releases_url":"https://api.github.com/repos/tellapart/Diamond/releases{/id}","created_at":"2014-11-13T17:30:49Z","updated_at":"2015-01-22T23:01:02Z","pushed_at":"2015-01-21T22:21:32Z","git_url":"git://github.com/tellapart/Diamond.git","ssh_url":"git@github.com:tellapart/Diamond.git","clone_url":"https://github.com/tellapart/Diamond.git","svn_url":"https://github.com/tellapart/Diamond","homepage":"","size":4371,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tellapart/Diamond/pulls/8"},"html":{"href":"https://github.com/tellapart/Diamond/pull/8"},"issue":{"href":"https://api.github.com/repos/tellapart/Diamond/issues/8"},"comments":{"href":"https://api.github.com/repos/tellapart/Diamond/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/tellapart/Diamond/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/tellapart/Diamond/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/tellapart/Diamond/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/tellapart/Diamond/statuses/456cfb7e94ee72e5d492984db945268f9716f263"}}}}