Skip to content

Commit

Permalink
Merge pull request #109 from diggyk/master
Browse files Browse the repository at this point in the history
BUGFIX: Monitoring failed on unknown hosts
  • Loading branch information
gmjosack committed Dec 10, 2015
2 parents 91d248c + be17dac commit 1843f6f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions bin/hermes
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def request_get(path):
if response.status_code < 500:
break

if response.status_code == requests.codes.not_found:
raise HermesNotFound("{} returned 404".format(
settings.hermes_server + path)
if 400 <= response.status_code < 500:
raise HermesNotFound("{} returned {}".format(
settings.hermes_server + path, response.status_code)
)

if response.status_code != requests.codes.ok or not response.content:
Expand All @@ -77,7 +77,7 @@ def request_get(path):
data = "Received invalid response: {}".format(response.content)

raise HermesException(
"Error: {}".format(data)
"Error: {} {} {}".format(response.status_code, requests.codes.ok, data)
)

return response
Expand Down Expand Up @@ -556,18 +556,18 @@ def list_host_labors_monitoring(args):
if time_left.days <= 5:
critical = True

except HermesNotFound as exc:
except HermesNotFound:
# if the error was that the hostname wasn't found, just return
# an empty list because hermes doesn't know about this host and
# so we can assume it has no open labors
labors = []

except HermesException as exc:
# FIXME -- add error codes to Hermes API and test for that
if exc.message.startswith("Error: No host"):
# if the error was that the hostname wasn't found, just return
# an empty list because hermes doesn't know about this host and
# so we can assume it has no open labors
labors = []
else:
print "UNKNOWN: 404 querying Hermes returned an exception"
print ""
traceback.print_exc(file=sys.stdout)
sys.exit(3)
print "UNKNOWN: Hermes returned an exception"
print ""
traceback.print_exc(file=sys.stdout)
sys.exit(3)

response = request_get("/api/v1/fates?limit=all&expand=eventtypes")
fates = response.json()["fates"]
Expand Down
2 changes: 1 addition & 1 deletion hermes/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.1"
__version__ = "0.7.2"

0 comments on commit 1843f6f

Please sign in to comment.