Skip to content

Commit

Permalink
Merge pull request #312 from /issues/311
Browse files Browse the repository at this point in the history
Issues/311 - 2.0.0 release
  • Loading branch information
jantman authored Oct 12, 2017
2 parents fb9379a + fb435a1 commit 049e92d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

2.0.0 (2017-10-12)
------------------

* Update README with correct boto version requirement. (Thanks to `nadlerjessie <https://github.com/nadlerjessie>`_ for the contribution.)
* Update minimum ``boto3`` version requirement from 1.2.3 to 1.4.4; the code for `Issue #268 <https://github.com/jantman/awslimitchecker/issues/268>`_ released in 0.11.0 requires boto3 >= 1.4.4 to make the ElasticLoadBalancing ``DescribeAccountLimits`` call.
* **Bug fix for "Running On-Demand EC2 instances" limit** - `Issue #308 <https://github.com/jantman/awslimitchecker/issues/308>`_ - The fix for `Issue #215 <https://github.com/jantman/awslimitchecker/issues/215>`_ / `PR #223 <https://github.com/jantman/awslimitchecker/pull/223>`_, released in 0.6.0 on November 11, 2016 was based on `incorrect information <https://github.com/jantman/awslimitchecker/issues/215#issuecomment-259144130>`_ about how Regional Benefit Reserved Instances (RIs) impact the service limit. The code implemented at that time subtracted Regional Benefit RIs from the count of running instances that we use to establish usage. Upon further review, as well as confirmation from AWS Support, some AWS TAMs, and the `relevant AWS documentation <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-reserved-instances.html#ri-limits>`_, only Zonal RIs (AZ-specific) are exempt from the Running On-Demand Instances limit. Regional Benefit RIs are counted the same as any other On-Demand Instances, as they don't have reserved capacity. This release stops subtracting Regional Benefit RIs from the count of Running Instances, which was causing awslimitchecker to report inaccurately low Running Instances usage.

1.0.0 (2017-09-21)
------------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Requirements

* Python 2.6, 2.7, 3.3+.
* Python `VirtualEnv <http://www.virtualenv.org/>`_ and ``pip`` (recommended installation method; your OS/distribution should have packages for these)
* `boto3 <http://boto3.readthedocs.org/>`_ >= 1.2.3
* `boto3 <http://boto3.readthedocs.org/>`_ >= 1.4.4

Installation and Usage
-----------------------
Expand Down
27 changes: 12 additions & 15 deletions awslimitchecker/services/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def _find_usage_instances(self):
inst_usage = self._instance_usage()
res_usage = self._get_reserved_instance_count()
logger.debug('Reserved instance count: %s', res_usage)
total_ris = 0
running_ris = 0
# subtract reservations from instance usage
ondemand_usage = defaultdict(int)
for az in inst_usage:
Expand All @@ -97,24 +99,19 @@ def _find_usage_instances(self):
ondemand_usage[i_type] += count
continue
od = count - res_usage[az][i_type]
if od < 1:
total_ris += res_usage[az][i_type]
if count < res_usage[az][i_type]:
running_ris += count
else:
running_ris += res_usage[az][i_type]
if od < 0:
# we have unused reservations
continue
ondemand_usage[i_type] += od
# subtract any "Regional Benefit" AZ-less reservations
for i_type in ondemand_usage.keys():
if RI_NO_AZ in res_usage and i_type in res_usage[RI_NO_AZ]:
logger.debug('Subtracting %d AZ-less "Regional Benefit" '
'Reserved Instances from %d running %s instances',
res_usage[RI_NO_AZ][i_type],
ondemand_usage[i_type], i_type)
# we have Regional Benefit reservations for this type;
# we don't want to show negative usage, even if we're
# over-reserved
ondemand_usage[i_type] = max(
ondemand_usage[i_type] - res_usage[RI_NO_AZ][i_type],
0
)
logger.debug(
'Found %d total RIs and %d running/used RIs',
total_ris, running_ris
)
total_instances = 0
for i_type, usage in ondemand_usage.items():
key = 'Running On-Demand {t} instances'.format(
Expand Down
6 changes: 3 additions & 3 deletions awslimitchecker/tests/services/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def test_find_usage_instances(self):
mock_res_inst_count.return_value = ri_count
cls._find_usage_instances()
assert mock_t2_micro.mock_calls == [call._add_current_usage(
35,
36,
aws_type='AWS::EC2::Instance'
)]
assert mock_r3_2xlarge.mock_calls == [call._add_current_usage(
Expand All @@ -334,11 +334,11 @@ def test_find_usage_instances(self):
aws_type='AWS::EC2::Instance'
)]
assert mock_c4_large.mock_calls == [call._add_current_usage(
0,
4,
aws_type='AWS::EC2::Instance'
)]
assert mock_all_ec2.mock_calls == [call._add_current_usage(
48,
53,
aws_type='AWS::EC2::Instance'
)]
assert mock_inst_usage.mock_calls == [call(cls)]
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 = (1, 0, 0)
_VERSION_TUP = (2, 0, 0)
_VERSION = '.'.join([str(x) for x in _VERSION_TUP])
_PROJECT_URL = 'https://github.com/jantman/awslimitchecker'

Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Requirements

* Python 2.6, 2.7, 3.3+.
* Python `VirtualEnv <http://www.virtualenv.org/>`_ and ``pip`` (recommended installation method; your OS/distribution should have packages for these)
* `boto3 <http://boto3.readthedocs.org/>`_ >= 1.2.3
* `boto3 <http://boto3.readthedocs.org/>`_ >= 1.4.4


.. _getting_started.installing:
Expand Down
10 changes: 6 additions & 4 deletions docs/source/limits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ updated from Trusted Advisor:

* Running On-Demand c4.xlarge instances

* Running On-Demand m1.small instances
* Running On-Demand m1.medium instances

* Running On-Demand m3.2xlarge instances

Expand Down Expand Up @@ -90,6 +90,8 @@ updated from Trusted Advisor:

* Running On-Demand t1.micro instances

* Running On-Demand t2.2xlarge instances

* Running On-Demand t2.large instances

* Running On-Demand t2.medium instances
Expand Down Expand Up @@ -412,8 +414,8 @@ Running On-Demand i3.8xlarge instances 2
Running On-Demand i3.large instances 2
Running On-Demand i3.xlarge instances 2
Running On-Demand m1.large instances 20
Running On-Demand m1.medium instances 20
Running On-Demand m1.small instances :sup:`(TA)` 20
Running On-Demand m1.medium instances :sup:`(TA)` 20
Running On-Demand m1.small instances 20
Running On-Demand m1.xlarge instances 20
Running On-Demand m2.2xlarge instances 20
Running On-Demand m2.4xlarge instances 20
Expand Down Expand Up @@ -443,7 +445,7 @@ Running On-Demand r4.8xlarge instances 20
Running On-Demand r4.large instances :sup:`(TA)` 20
Running On-Demand r4.xlarge instances 20
Running On-Demand t1.micro instances :sup:`(TA)` 20
Running On-Demand t2.2xlarge instances 20
Running On-Demand t2.2xlarge instances :sup:`(TA)` 20
Running On-Demand t2.large instances :sup:`(TA)` 20
Running On-Demand t2.medium instances :sup:`(TA)` 20
Running On-Demand t2.micro instances :sup:`(TA)` 20
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
long_description = file.read()

requires = [
'boto3>=1.2.3',
'boto3>=1.4.4',
'termcolor>=1.1.0',
'python-dateutil>=2.4.2',
'versionfinder>=0.1.1',
Expand Down

0 comments on commit 049e92d

Please sign in to comment.