{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/comments/33180900","id":33180900,"diff_hunk":"@@ -178,6 +188,28 @@\n       (let [{:keys [status]} (http-client/get \"http://localhost:8180/status/v1/services\")]\n         (is (= 200 status))))))\n \n+(deftest status-check-error-handling-test\n+  (with-status-service\n+    app\n+    [slow-service\n+     broken-service]\n+  (testing \"handles case when a status check times out\"\n+    (with-redefs [puppetlabs.trapperkeeper.services.status.status-core/check-timeout (constantly 1)]\n+      (let [resp (http-client/get \"http://localhost:8180/status/v1/services/slow?level=critical\")\n+            body (json/parse-string (slurp (:body resp)))]\n+        (is (= 503 (:status resp)))\n+        (is (= \"unknown\"\n+               (get body \"state\")))\n+        (is (re-find #\"timed out\" (get body \"status\"))))))\n+\n+  (testing \"handles case when a status check throws an exception\"\n+    (let [resp (http-client/get \"http://localhost:8180/status/v1/services/broken?level=critical\")\n+            body (json/parse-string (slurp (:body resp)))]\n+        (is (= 503 (:status resp)))\n+        (is (= \"unknown\"\n+               (get body \"state\")))\n+        (is (re-find #\"exception.*don't\" (get body \"status\")))))))\n+","path":"test/puppetlabs/trapperkeeper/services/status/status_service_test.clj","position":51,"original_position":51,"commit_id":"faa566a6e3083a27f0c970dc7c993f4ca5e2a24f","original_commit_id":"faa566a6e3083a27f0c970dc7c993f4ca5e2a24f","user":{"login":"aperiodic","id":115510,"avatar_url":"https://avatars.githubusercontent.com/u/115510?v=3","gravatar_id":"","url":"https://api.github.com/users/aperiodic","html_url":"https://github.com/aperiodic","followers_url":"https://api.github.com/users/aperiodic/followers","following_url":"https://api.github.com/users/aperiodic/following{/other_user}","gists_url":"https://api.github.com/users/aperiodic/gists{/gist_id}","starred_url":"https://api.github.com/users/aperiodic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aperiodic/subscriptions","organizations_url":"https://api.github.com/users/aperiodic/orgs","repos_url":"https://api.github.com/users/aperiodic/repos","events_url":"https://api.github.com/users/aperiodic/events{/privacy}","received_events_url":"https://api.github.com/users/aperiodic/received_events","type":"User","site_admin":false},"body":"I think there should still be an explicit test of the behavior when a service returns a non-conformant status response, it just doesn't need a new service to do it.","created_at":"2015-06-24T18:38:56Z","updated_at":"2015-06-24T18:38:56Z","html_url":"https://github.com/puppetlabs/trapperkeeper-status/pull/26#discussion_r33180900","pull_request_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/comments/33180900"},"html":{"href":"https://github.com/puppetlabs/trapperkeeper-status/pull/26#discussion_r33180900"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26","id":38284028,"html_url":"https://github.com/puppetlabs/trapperkeeper-status/pull/26","diff_url":"https://github.com/puppetlabs/trapperkeeper-status/pull/26.diff","patch_url":"https://github.com/puppetlabs/trapperkeeper-status/pull/26.patch","issue_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/issues/26","number":26,"state":"open","locked":false,"title":"(TK-175) Add error handling for status check functions","user":{"login":"nathanielksmith","id":98482,"avatar_url":"https://avatars.githubusercontent.com/u/98482?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanielksmith","html_url":"https://github.com/nathanielksmith","followers_url":"https://api.github.com/users/nathanielksmith/followers","following_url":"https://api.github.com/users/nathanielksmith/following{/other_user}","gists_url":"https://api.github.com/users/nathanielksmith/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielksmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielksmith/subscriptions","organizations_url":"https://api.github.com/users/nathanielksmith/orgs","repos_url":"https://api.github.com/users/nathanielksmith/repos","events_url":"https://api.github.com/users/nathanielksmith/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielksmith/received_events","type":"User","site_admin":false},"body":"This commit adds special handling around the calling of status check\r\nfunctions. Specifically, it handles these cases:\r\n\r\n * Status check function times out\r\n * Status check function throws an Exception\r\n * Status check function returns something that doesn't conform to the\r\n   callback response schema\r\n\r\nIn each error case, is_running is set to unknown and a descriptive\r\nstatus key is set.\r\n\r\nNote that none of these cases are reflected in the eventual TK status\r\nservice HTTP responses as that was not part of the specification of this\r\nticket.","created_at":"2015-06-22T22:32:59Z","updated_at":"2015-06-24T18:38:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0bdf9800c0b2e348be727c95e8fae8b03b48db7a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/issues/26/comments","statuses_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/statuses/faa566a6e3083a27f0c970dc7c993f4ca5e2a24f","head":{"label":"nathanielksmith:tk-175-error-handling","ref":"tk-175-error-handling","sha":"faa566a6e3083a27f0c970dc7c993f4ca5e2a24f","user":{"login":"nathanielksmith","id":98482,"avatar_url":"https://avatars.githubusercontent.com/u/98482?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanielksmith","html_url":"https://github.com/nathanielksmith","followers_url":"https://api.github.com/users/nathanielksmith/followers","following_url":"https://api.github.com/users/nathanielksmith/following{/other_user}","gists_url":"https://api.github.com/users/nathanielksmith/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielksmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielksmith/subscriptions","organizations_url":"https://api.github.com/users/nathanielksmith/orgs","repos_url":"https://api.github.com/users/nathanielksmith/repos","events_url":"https://api.github.com/users/nathanielksmith/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielksmith/received_events","type":"User","site_admin":false},"repo":{"id":36469027,"name":"trapperkeeper-status","full_name":"nathanielksmith/trapperkeeper-status","owner":{"login":"nathanielksmith","id":98482,"avatar_url":"https://avatars.githubusercontent.com/u/98482?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanielksmith","html_url":"https://github.com/nathanielksmith","followers_url":"https://api.github.com/users/nathanielksmith/followers","following_url":"https://api.github.com/users/nathanielksmith/following{/other_user}","gists_url":"https://api.github.com/users/nathanielksmith/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielksmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielksmith/subscriptions","organizations_url":"https://api.github.com/users/nathanielksmith/orgs","repos_url":"https://api.github.com/users/nathanielksmith/repos","events_url":"https://api.github.com/users/nathanielksmith/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielksmith/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nathanielksmith/trapperkeeper-status","description":"Trapperkeeper Status Service","fork":true,"url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status","forks_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/forks","keys_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/teams","hooks_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/hooks","issue_events_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/issues/events{/number}","events_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/events","assignees_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/assignees{/user}","branches_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/branches{/branch}","tags_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/tags","blobs_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/git/refs{/sha}","trees_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/statuses/{sha}","languages_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/languages","stargazers_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/stargazers","contributors_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/contributors","subscribers_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/subscribers","subscription_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/subscription","commits_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/commits{/sha}","git_commits_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/git/commits{/sha}","comments_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/comments{/number}","issue_comment_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/issues/comments{/number}","contents_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/contents/{+path}","compare_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/merges","archive_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/downloads","issues_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/issues{/number}","pulls_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/pulls{/number}","milestones_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/milestones{/number}","notifications_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/labels{/name}","releases_url":"https://api.github.com/repos/nathanielksmith/trapperkeeper-status/releases{/id}","created_at":"2015-05-28T22:12:58Z","updated_at":"2015-05-28T22:12:58Z","pushed_at":"2015-06-24T17:43:11Z","git_url":"git://github.com/nathanielksmith/trapperkeeper-status.git","ssh_url":"git@github.com:nathanielksmith/trapperkeeper-status.git","clone_url":"https://github.com/nathanielksmith/trapperkeeper-status.git","svn_url":"https://github.com/nathanielksmith/trapperkeeper-status","homepage":null,"size":183,"stargazers_count":0,"watchers_count":0,"language":"Clojure","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":"puppetlabs:master","ref":"master","sha":"657837d6e03cd8e26e31d25f0b56996d075e31e4","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":33000992,"name":"trapperkeeper-status","full_name":"puppetlabs/trapperkeeper-status","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/trapperkeeper-status","description":"Trapperkeeper Status Service","fork":false,"url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status","forks_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/forks","keys_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/teams","hooks_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/events","assignees_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/tags","blobs_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/subscription","commits_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/merges","archive_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/downloads","issues_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/releases{/id}","created_at":"2015-03-27T17:54:03Z","updated_at":"2015-05-08T20:57:04Z","pushed_at":"2015-06-24T18:16:25Z","git_url":"git://github.com/puppetlabs/trapperkeeper-status.git","ssh_url":"git@github.com:puppetlabs/trapperkeeper-status.git","clone_url":"https://github.com/puppetlabs/trapperkeeper-status.git","svn_url":"https://github.com/puppetlabs/trapperkeeper-status","homepage":null,"size":502,"stargazers_count":1,"watchers_count":1,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":2,"forks":9,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26"},"html":{"href":"https://github.com/puppetlabs/trapperkeeper-status/pull/26"},"issue":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/issues/26"},"comments":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/trapperkeeper-status/statuses/faa566a6e3083a27f0c970dc7c993f4ca5e2a24f"}}}}