From c8b9e0f028943185fffa91b74b034cd71e58be6a Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Mon, 5 Aug 2019 23:06:05 -0400 Subject: [PATCH 1/5] NOFORN - Limits for ALBs and Classic LBs are now provided separately --- awslimitchecker/services/elb.py | 23 +++++++++++++++---- awslimitchecker/tests/services/test_elb.py | 17 ++++++++++---- docs/examples/check_aws_limits.py | 2 +- .../us-east-1/limit_overrides.json | 2 +- docs/source/limits.rst | 3 ++- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/awslimitchecker/services/elb.py b/awslimitchecker/services/elb.py index 25879898..ffde8aa5 100644 --- a/awslimitchecker/services/elb.py +++ b/awslimitchecker/services/elb.py @@ -74,10 +74,14 @@ def find_usage(self): elb_usage = self._find_usage_elbv1() alb_usage = self._find_usage_elbv2() logger.debug('ELBs in use: %d, ALBs in use: %d', elb_usage, alb_usage) - self.limits['Active load balancers']._add_current_usage( - (elb_usage + alb_usage), + self.limits['Classic load balancers']._add_current_usage( + elb_usage, aws_type='AWS::ElasticLoadBalancing::LoadBalancer', ) + self.limits['Application load balancers']._add_current_usage( + alb_usage, + aws_type='AWS::ElasticLoadBalancingV2::LoadBalancer', + ) self._have_usage = True logger.debug("Done checking usage.") @@ -260,8 +264,8 @@ def get_limits(self): return self.limits limits = {} # ELBv1 (Classic ELB) limits - limits['Active load balancers'] = AwsLimit( - 'Active load balancers', + limits['Classic load balancers'] = AwsLimit( + 'Classic load balancers', self, 20, self.warning_threshold, @@ -287,6 +291,14 @@ def get_limits(self): limit_subtype='Instance' ) # ELBv2 (ALB) limits + limits['Application load balancers'] = AwsLimit( + 'Application load balancers', + self, + 20, + self.warning_threshold, + self.critical_threshold, + limit_type='AWS::ElasticLoadBalancingV2::LoadBalancer', + ) limits['Target groups'] = AwsLimit( 'Target groups', self, @@ -352,7 +364,7 @@ def _update_limits_from_api(self): logger.debug("Querying ELB DescribeAccountLimits for limits") attribs = self.conn.describe_account_limits() name_to_limits = { - 'classic-load-balancers': 'Active load balancers', + 'classic-load-balancers': 'Classic load balancers', 'classic-listeners': 'Listeners per load balancer', 'classic-registered-instances': 'Registered instances per load balancer' @@ -371,6 +383,7 @@ def _update_limits_from_api(self): logger.debug("Querying ELBv2 (ALB) DescribeAccountLimits for limits") attribs = self.conn2.describe_account_limits() name_to_limits = { + 'application-load-balancers': 'Application load balancers', 'target-groups': 'Target groups', 'listeners-per-application-load-balancer': 'Listeners per application load balancer', diff --git a/awslimitchecker/tests/services/test_elb.py b/awslimitchecker/tests/services/test_elb.py index b835b723..076248ca 100644 --- a/awslimitchecker/tests/services/test_elb.py +++ b/awslimitchecker/tests/services/test_elb.py @@ -71,8 +71,9 @@ def test_get_limits(self): cls.limits = {} res = cls.get_limits() assert sorted(res.keys()) == sorted([ - 'Active load balancers', + 'Application load balancers', 'Certificates per application load balancer', + 'Classic load balancers', 'Listeners per application load balancer', 'Listeners per load balancer', 'Listeners per network load balancer', @@ -119,7 +120,8 @@ def test_update_limits_from_api(self): call('elbv2', foo='bar', baz='blam'), call().describe_account_limits() ] - assert cls.limits['Active load balancers'].api_limit == 3 + assert cls.limits['Classic load balancers'].api_limit == 3 + assert cls.limits['Application load balancers'].api_limit == 6 assert cls.limits['Listeners per load balancer'].api_limit == 5 assert cls.limits[ 'Registered instances per load balancer'].api_limit == 1800 @@ -142,9 +144,14 @@ def test_find_usage(self): assert cls._have_usage is True assert mock_v1.mock_calls == [call(cls)] assert mock_v2.mock_calls == [call(cls)] - assert len(cls.limits['Active load balancers'].get_current_usage()) == 1 - assert cls.limits['Active load balancers' - ''].get_current_usage()[0].get_value() == 8 + assert len(cls.limits[ + 'Classic load balancers'].get_current_usage()) == 1 + assert len(cls.limits[ + 'Application load balancers'].get_current_usage()) == 1 + assert cls.limits[ + 'Classic load balancers'].get_current_usage()[0].get_value() == 3 + assert cls.limits['Application load balancers' + ].get_current_usage()[0].get_value() == 5 def test_find_usage_elbv1(self): mock_conn = Mock() diff --git a/docs/examples/check_aws_limits.py b/docs/examples/check_aws_limits.py index 94871ce3..8c80c3f3 100755 --- a/docs/examples/check_aws_limits.py +++ b/docs/examples/check_aws_limits.py @@ -67,7 +67,7 @@ 'Running On-Demand c1.medium instances': 1000, }, 'ELB': { - 'Active load balancers': 100, + 'Application load balancers': 100, }, } diff --git a/docs/examples/multi-region_multi-account/config/111111111111/us-east-1/limit_overrides.json b/docs/examples/multi-region_multi-account/config/111111111111/us-east-1/limit_overrides.json index f6082768..88a0b0ff 100644 --- a/docs/examples/multi-region_multi-account/config/111111111111/us-east-1/limit_overrides.json +++ b/docs/examples/multi-region_multi-account/config/111111111111/us-east-1/limit_overrides.json @@ -12,6 +12,6 @@ "Running On-Demand c1.medium instances": 1000 }, "ELB": { - "Active load balancers": 100 + "Application load balancers": 100 } } \ No newline at end of file diff --git a/docs/source/limits.rst b/docs/source/limits.rst index 8e7cbbc4..bcdf8758 100644 --- a/docs/source/limits.rst +++ b/docs/source/limits.rst @@ -372,8 +372,9 @@ ELB ========================================== =============== ======= ==== Limit Trusted Advisor API Default ========================================== =============== ======= ==== -Active load balancers |check| |check| 20 +Application load balancers |check| 20 Certificates per application load balancer 25 +Classic load balancers |check| |check| 20 Listeners per application load balancer |check| 50 Listeners per load balancer |check| 100 Listeners per network load balancer |check| 50 From 733900f65d16224f29dc939e86def1f7bc4fb5ac Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Tue, 13 Aug 2019 11:08:30 -0400 Subject: [PATCH 2/5] 7.0.0 version bump and CHANGELOG. --- CHANGES.rst | 5 ++++- awslimitchecker/version.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2574c3b1..3677e688 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,9 +1,12 @@ Changelog ========= -Unreleased Changes +7.0.0 (2019-08-13) ------------------ +This release **removes one limit and adds two new limits**! + +* `Issue #412 `__ / `PR #414 `__ - Since some time in June 2019, the former ``ELB`` Service ``Active load balancers`` limit is now two separate limits, ``Classic load balancers`` and ``Application load balancers``. **Anyone who was using the "Active load balancers" limit name (e.g. in overrides or custom code) must update their code accordingly.** This release removes the ``Active load balancers`` limit and adds two new limits, ``Classic load balancers`` and ``Application load balancers``, to match how AWS now calculates and exposes these limits. * `Issue #410 `__ - Documentation fix for missing Trusted Advisor information on Limits page. 6.1.7 (2019-05-17) diff --git a/awslimitchecker/version.py b/awslimitchecker/version.py index f968cfc0..8faf2a14 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 = (6, 1, 7) +_VERSION_TUP = (7, 0, 0) _VERSION = '.'.join([str(x) for x in _VERSION_TUP]) _PROJECT_URL = 'https://github.com/jantman/awslimitchecker' From c6351b9767ad622c201ee0dbd5f7daedb33b254d Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Tue, 13 Aug 2019 11:08:53 -0400 Subject: [PATCH 3/5] pytest error fix --- CHANGES.rst | 1 + awslimitchecker/tests/test_utils.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3677e688..2ba1aa30 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,7 @@ This release **removes one limit and adds two new limits**! * `Issue #412 `__ / `PR #414 `__ - Since some time in June 2019, the former ``ELB`` Service ``Active load balancers`` limit is now two separate limits, ``Classic load balancers`` and ``Application load balancers``. **Anyone who was using the "Active load balancers" limit name (e.g. in overrides or custom code) must update their code accordingly.** This release removes the ``Active load balancers`` limit and adds two new limits, ``Classic load balancers`` and ``Application load balancers``, to match how AWS now calculates and exposes these limits. * `Issue #410 `__ - Documentation fix for missing Trusted Advisor information on Limits page. +* Fix some test failures related to exception objects in pytest 5.0.0. 6.1.7 (2019-05-17) ------------------ diff --git a/awslimitchecker/tests/test_utils.py b/awslimitchecker/tests/test_utils.py index 1186c515..a6e2825a 100644 --- a/awslimitchecker/tests/test_utils.py +++ b/awslimitchecker/tests/test_utils.py @@ -157,7 +157,7 @@ def test_no_marker_path(self): paginate_dict(func) ex_str = "alc_marker_path must be specified for queries " \ "that return a dict." - assert ex_str in str(excinfo) + assert ex_str in str(excinfo.value) def test_no_data_path(self): func = Mock() @@ -166,7 +166,7 @@ def test_no_data_path(self): paginate_dict(func, alc_marker_path=[]) ex_str = "alc_data_path must be specified for queries " \ "that return a dict." - assert ex_str in str(excinfo) + assert ex_str in str(excinfo.value) def test_no_marker_param(self): func = Mock() @@ -179,7 +179,7 @@ def test_no_marker_param(self): ) ex_str = "alc_marker_param must be specified for queries " \ "that return a dict." - assert ex_str in str(excinfo) + assert ex_str in str(excinfo.value) def test_bad_path(self): result = { From 3ebceae418abe6bbe92a8f7592eef12f495feb98 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Tue, 13 Aug 2019 11:44:46 -0400 Subject: [PATCH 4/5] docs - fix broken pytest link --- docs/source/development.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/development.rst b/docs/source/development.rst index bf3e3d22..dc3446da 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -209,7 +209,7 @@ For further information, see :ref:`Internals / Trusted Advisor `_, driven by `tox `_. +Testing is done via `pytest `_, driven by `tox `_. * testing is as simple as: From f7a85d2726ae1b7cd7f2c9db8469e523d24484bb Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Tue, 13 Aug 2019 13:14:27 -0400 Subject: [PATCH 5/5] locally rebuild docs --- docs/source/cli_usage.rst | 21 ++++++++++----------- docs/source/limits.rst | 12 ++++++------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/docs/source/cli_usage.rst b/docs/source/cli_usage.rst index b9973407..8051bab0 100644 --- a/docs/source/cli_usage.rst +++ b/docs/source/cli_usage.rst @@ -25,14 +25,13 @@ use as a Nagios-compatible plugin). (venv)$ awslimitchecker --help usage: awslimitchecker [-h] [-S [SERVICE [SERVICE ...]]] - [--skip-service SKIP_SERVICE] [-s] [-l] - [--skip-check SKIP_CHECK] - [--list-defaults] [-L LIMIT] [-u] [--iam-policy] - [-W WARNING_THRESHOLD] [-C CRITICAL_THRESHOLD] - [-P PROFILE_NAME] [-A STS_ACCOUNT_ID] - [-R STS_ACCOUNT_ROLE] [-E EXTERNAL_ID] - [-M MFA_SERIAL_NUMBER] [-T MFA_TOKEN] [-r REGION] - [--skip-ta] + [--skip-service SKIP_SERVICE] [--skip-check SKIP_CHECK] + [-s] [-l] [--list-defaults] [-L LIMIT] [-u] + [--iam-policy] [-W WARNING_THRESHOLD] + [-C CRITICAL_THRESHOLD] [-P PROFILE_NAME] + [-A STS_ACCOUNT_ID] [-R STS_ACCOUNT_ROLE] + [-E EXTERNAL_ID] [-M MFA_SERIAL_NUMBER] [-T MFA_TOKEN] + [-r REGION] [--skip-ta] [--ta-refresh-wait | --ta-refresh-trigger | --ta-refresh-older TA_REFRESH_OLDER] [--ta-refresh-timeout TA_REFRESH_TIMEOUT] [--no-color] [--no-check-version] [-v] [-V] @@ -48,7 +47,7 @@ use as a Nagios-compatible plugin). avoid performing actions for the specified service name; see -s|--list-services for valid names --skip-check SKIP_CHECK - avoid performing actions for the specified check + avoid performing actions for the specified check name -s, --list-services print a list of all AWS service types that awslimitchecker knows how to check -l, --list-limits print all AWS effective limits in @@ -391,10 +390,10 @@ permissions for it to perform all limit checks. This can be viewed with the "Statement": [ { "Action": [ - "apigateway:GET", + "apigateway:GET", (...) } - ], + ], "Version": "2012-10-17" } diff --git a/docs/source/limits.rst b/docs/source/limits.rst index bcdf8758..34ce94ea 100644 --- a/docs/source/limits.rst +++ b/docs/source/limits.rst @@ -249,7 +249,7 @@ Running On-Demand m5.24xlarge instances 5 Running On-Demand m5.2xlarge instances 20 Running On-Demand m5.4xlarge instances 10 Running On-Demand m5.large instances |check| 20 -Running On-Demand m5.xlarge instances |check| 20 +Running On-Demand m5.xlarge instances 20 Running On-Demand m5a.12xlarge instances 20 Running On-Demand m5a.24xlarge instances 20 Running On-Demand m5a.2xlarge instances 20 @@ -276,7 +276,7 @@ Running On-Demand r3.large instances 20 Running On-Demand r3.xlarge instances 20 Running On-Demand r4.16xlarge instances 1 Running On-Demand r4.2xlarge instances 20 -Running On-Demand r4.4xlarge instances 10 +Running On-Demand r4.4xlarge instances |check| 10 Running On-Demand r4.8xlarge instances 5 Running On-Demand r4.large instances |check| 20 Running On-Demand r4.xlarge instances |check| 20 @@ -286,7 +286,7 @@ Running On-Demand r5.24xlarge instances 20 Running On-Demand r5.2xlarge instances 20 Running On-Demand r5.4xlarge instances 20 Running On-Demand r5.8xlarge instances 20 -Running On-Demand r5.large instances 20 +Running On-Demand r5.large instances |check| 20 Running On-Demand r5.metal instances 20 Running On-Demand r5.xlarge instances 20 Running On-Demand r5a.12xlarge instances 20 @@ -317,7 +317,7 @@ Running On-Demand t3.large instances |check| 20 Running On-Demand t3.medium instances |check| 20 Running On-Demand t3.micro instances |check| 20 Running On-Demand t3.nano instances 20 -Running On-Demand t3.small instances 20 +Running On-Demand t3.small instances |check| 20 Running On-Demand t3.xlarge instances 20 Running On-Demand x1.16xlarge instances 20 Running On-Demand x1.32xlarge instances 20 @@ -374,7 +374,7 @@ Limit Trusted Advisor API Default ========================================== =============== ======= ==== Application load balancers |check| 20 Certificates per application load balancer 25 -Classic load balancers |check| |check| 20 +Classic load balancers |check| 20 Listeners per application load balancer |check| 50 Listeners per load balancer |check| 100 Listeners per network load balancer |check| 50 @@ -470,7 +470,7 @@ DB Clusters |check| |check| 40 DB instances |check| |check| 40 DB parameter groups |check| |check| 50 DB security groups |check| |check| 25 -DB snapshots per user |check| |check| 100 +DB snapshots per user |check| 100 Event Subscriptions |check| |check| 20 Max auths per security group |check| |check| 20 Option Groups |check| 20