From 6fb506ee07ae41ad7cb4c1d4298723e632faa72c Mon Sep 17 00:00:00 2001 From: Jessie Nadler Date: Thu, 28 Sep 2017 15:07:48 -0400 Subject: [PATCH 1/5] Update README to require boto3 >= 1.4.4 --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5157c79b..e07ca52d 100644 --- a/README.rst +++ b/README.rst @@ -107,7 +107,7 @@ Requirements * Python 2.6, 2.7, 3.3+. * Python `VirtualEnv `_ and ``pip`` (recommended installation method; your OS/distribution should have packages for these) -* `boto3 `_ >= 1.2.3 +* `boto3 `_ >= 1.4.4 Installation and Usage ----------------------- From 20fd3ca70ad565c4de8670b179435a45b00b392c Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Thu, 12 Oct 2017 13:17:26 -0400 Subject: [PATCH 2/5] fixes #308 - stop subtracting Regional Benefit RIs from On-Demand Running Instances usage --- CHANGES.rst | 6 +++++ awslimitchecker/services/ec2.py | 27 ++++++++++------------ awslimitchecker/tests/services/test_ec2.py | 6 ++--- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 488a4f05..86bde71a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,12 @@ Changelog ========= +Unreleased Changes +------------------ + +* Update README with correct boto version requirement. (Thanks to `nadlerjessie `_ for the contribution.) +* **Bug fix for "Running On-Demand EC2 instances" limit** - `Issue #308 `_ - The fix for `Issue #215 `_ / `PR #223 `_, released in 0.6.0 on November 11, 2016 was based on `incorrect information `_ 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 `_, 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) ------------------ diff --git a/awslimitchecker/services/ec2.py b/awslimitchecker/services/ec2.py index 4afe80b3..4ba74e18 100644 --- a/awslimitchecker/services/ec2.py +++ b/awslimitchecker/services/ec2.py @@ -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: @@ -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( diff --git a/awslimitchecker/tests/services/test_ec2.py b/awslimitchecker/tests/services/test_ec2.py index bb66a383..2ca3b4d0 100644 --- a/awslimitchecker/tests/services/test_ec2.py +++ b/awslimitchecker/tests/services/test_ec2.py @@ -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( @@ -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)] From c14b848fff25e51c0b3c7abac2ad7eb41fa831c6 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Thu, 12 Oct 2017 13:23:37 -0400 Subject: [PATCH 3/5] bump boto3 required version to 1.4.4, for ELB DescribeAccountLimits --- CHANGES.rst | 1 + docs/source/getting_started.rst | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 86bde71a..a8920ee0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,7 @@ Unreleased Changes ------------------ * Update README with correct boto version requirement. (Thanks to `nadlerjessie `_ for the contribution.) +* Update minimum ``boto3`` version requirement from 1.2.3 to 1.4.4; the code for `Issue #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 `_ - The fix for `Issue #215 `_ / `PR #223 `_, released in 0.6.0 on November 11, 2016 was based on `incorrect information `_ 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 `_, 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) diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 178f108c..fe687a26 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -59,7 +59,7 @@ Requirements * Python 2.6, 2.7, 3.3+. * Python `VirtualEnv `_ and ``pip`` (recommended installation method; your OS/distribution should have packages for these) -* `boto3 `_ >= 1.2.3 +* `boto3 `_ >= 1.4.4 .. _getting_started.installing: diff --git a/setup.py b/setup.py index 22ac0c7f..83365bd1 100644 --- a/setup.py +++ b/setup.py @@ -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', From 2b607689e3dc3efb1e16ce01e70a302320fe3874 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Thu, 12 Oct 2017 14:01:40 -0400 Subject: [PATCH 4/5] rebuild docs --- docs/source/limits.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/source/limits.rst b/docs/source/limits.rst index 09cea3ed..be816eea 100644 --- a/docs/source/limits.rst +++ b/docs/source/limits.rst @@ -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 @@ -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 @@ -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 @@ -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 From fb435a1afe3f132e2c30bf9a00a2d00ee68bcc62 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Thu, 12 Oct 2017 14:04:51 -0400 Subject: [PATCH 5/5] fixes #311 - bump version to 2.0.0 --- CHANGES.rst | 2 +- awslimitchecker/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a8920ee0..9faf7901 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,7 @@ Changelog ========= -Unreleased Changes +2.0.0 (2017-10-12) ------------------ * Update README with correct boto version requirement. (Thanks to `nadlerjessie `_ for the contribution.) diff --git a/awslimitchecker/version.py b/awslimitchecker/version.py index 619a4eda..f9db9748 100644 --- a/awslimitchecker/version.py +++ b/awslimitchecker/version.py @@ -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'