Skip to content

Commit

Permalink
Fixes #475 - if Alert Provider is used, only exit non-zero if an exce…
Browse files Browse the repository at this point in the history
…ption is thrown
  • Loading branch information
jantman committed Sep 21, 2020
1 parent c8bb91b commit 0ecc7ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Unreleased Changes

* `Issue #477 <https://github.com/jantman/awslimitchecker/issues/477>`__ - EC2 instances running on Dedicated Hosts (tenancy "host") or single-tenant hardware (tenancy "dedicated") do not count towards On-Demand Instances limits. They were previously being counted towards these limits; they are now excluded from the count.
* `Issue #477 <https://github.com/jantman/awslimitchecker/issues/477>`__ - For all VPC resources that support the ``owner-id`` filter, supply that filter when describing them, set to the current account ID. This will prevent shared resources from other accounts from being counted against the limits.
* `Issue #475 <https://github.com/jantman/awslimitchecker/issues/475>`__ - When an Alert Provider is used, only exit non-zero if an exception is encountered. Exit zero even if there are warnings and/or criticals.

.. _changelog.8_1_0:

Expand Down
2 changes: 2 additions & 0 deletions awslimitchecker/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ def console_entry_point(self):
)
else:
alerter.on_success(duration=time.time() - start_time)
# with alert provider, always exit zero
raise SystemExit(0)
raise SystemExit(res)


Expand Down
4 changes: 2 additions & 2 deletions awslimitchecker/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ def test_check_thresholds_warn_with_alerter(self):
type(mock_alc.return_value).region_name = mock_rn
mock_ct.return_value = 1, {'Foo': 'bar'}, 'FooBar'
self.cls.console_entry_point()
assert excinfo.value.code == 1
assert excinfo.value.code == 0
assert mock_ct.mock_calls == [
call(self.cls, None)
]
Expand Down Expand Up @@ -1929,7 +1929,7 @@ def test_check_thresholds_crit_with_alerter(self):
type(mock_alc.return_value).region_name = mock_rn
mock_ct.return_value = 2, {'Foo': 'bar'}, 'FooBar'
self.cls.console_entry_point()
assert excinfo.value.code == 2
assert excinfo.value.code == 0
assert mock_ct.mock_calls == [
call(self.cls, None)
]
Expand Down

0 comments on commit 0ecc7ef

Please sign in to comment.