Skip to content

Commit

Permalink
Merge pull request #462 from /issues/461
Browse files Browse the repository at this point in the history
fixes #461 - 8.0.2 release
  • Loading branch information
jantman committed Mar 3, 2020
2 parents 37e843b + a239b0e commit 2bb3ae7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

.. _changelog.8_0_2:

8.0.2 (2020-03-03)
------------------

* `PR #458 <https://github.com/jantman/awslimitchecker/pull/458>`_ - Fix for ZeroDivisionError on some Service Quotas limits that report as having a limit of zero. Thanks to `@deimosfr <https://github.com/deimosfr>`__.

.. _changelog.8_0_1:

8.0.1 (2019-12-28)
Expand Down
2 changes: 1 addition & 1 deletion awslimitchecker/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class instance. Return True if usage is within thresholds, or false if
for u in self._current_usage:
usage = u.get_value()
limit = u.get_maximum() or self.get_limit()
if limit is None:
if limit is None or limit == 0:
continue
pct = (usage / (limit * 1.0)) * 100
if crit_int is not None and usage >= crit_int:
Expand Down
4 changes: 2 additions & 2 deletions awslimitchecker/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def param_for_integration_test_verify_usage(metafunc):
False
],
[
{'region': 'sa-east-1'},
{'region': 'ap-southeast-1'},
'normal',
None,
False,
Expand Down Expand Up @@ -278,7 +278,7 @@ def param_for_integration_test_verify_limits(metafunc):
False
],
[
{'region': 'sa-east-1'},
{'region': 'ap-southeast-1'},
'normal',
None,
True,
Expand Down
20 changes: 20 additions & 0 deletions awslimitchecker/tests/test_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,26 @@ def test_ta_unlimited(self):
assert mock_get_thresh.mock_calls == [call()]
assert mock_get_limit.mock_calls == [call(), call(), call()]

def test_ta_zero(self):
limit = AwsLimit('limitname', self.mock_svc, 3, 1, 2)
u1 = AwsLimitUsage(limit, 4, resource_id='foo4bar')
u2 = AwsLimitUsage(limit, 3, resource_id='foo3bar')
u3 = AwsLimitUsage(limit, 2, resource_id='foo2bar')
limit._current_usage = [u1, u2, u3]
limit._set_ta_unlimited()
with patch('awslimitchecker.limit.AwsLimit.'
'_get_thresholds') as mock_get_thresh:
with patch('awslimitchecker.limit.AwsLimit.get_'
'limit') as mock_get_limit:
mock_get_thresh.return_value = (None, 40, None, 80)
mock_get_limit.return_value = 0
res = limit.check_thresholds()
assert res is True
assert limit._warnings == []
assert limit._criticals == []
assert mock_get_thresh.mock_calls == [call()]
assert mock_get_limit.mock_calls == [call(), call(), call()]

def test_pct_warn(self):
limit = AwsLimit('limitname', self.mock_svc, 100, 1, 2)
u1 = AwsLimitUsage(limit, 4, resource_id='foo4bar')
Expand Down
2 changes: 1 addition & 1 deletion awslimitchecker/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
except ImportError:
logger.error("Unable to import versionfinder", exc_info=True)

_VERSION_TUP = (8, 0, 1)
_VERSION_TUP = (8, 0, 2)
_VERSION = '.'.join([str(x) for x in _VERSION_TUP])
_PROJECT_URL = 'https://github.com/jantman/awslimitchecker'

Expand Down

0 comments on commit 2bb3ae7

Please sign in to comment.