Skip to content

Commit

Permalink
Merge pull request #517 from sebasrp/issues/514
Browse files Browse the repository at this point in the history
Fixes #514 - EKS Fargate profile usage check error
  • Loading branch information
jantman committed Apr 20, 2021
2 parents 0dba700 + 5fa7ac6 commit b6b2e84
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 64 deletions.
4 changes: 3 additions & 1 deletion awslimitchecker/services/eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def _find_clusters_usage(self):
aws_type='AWS::EKS::FargateProfile')

for selector in profile_selectors:
label_pairs = selector['labels']
label_pairs = selector.get('labels')
if label_pairs is None:
continue
self.limits[
'Label pairs per Fargate profile selector'
]._add_current_usage(
Expand Down
11 changes: 11 additions & 0 deletions awslimitchecker/tests/services/result_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4632,6 +4632,7 @@ class EKS(object):
'fargateProfileNames': [
'bar',
'baz',
'profile_no_labels',
]
}
]
Expand Down Expand Up @@ -4697,5 +4698,15 @@ class EKS(object):
},
],
}
},
{
'fargateProfile': {
'fargateProfileName': 'profile_no_labels',
'selectors': [
{
'namespace': "test_namespace1",
},
],
}
}
]
8 changes: 6 additions & 2 deletions awslimitchecker/tests/services/test_eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def test_find_clusters_usage(self):
clusterName=ANY,
fargateProfileName=ANY
),
call.describe_fargate_profile(
clusterName=ANY,
fargateProfileName=ANY
),
]
assert len(cls.limits[clusters_limit_key].get_current_usage()) == 1
assert cls.limits[clusters_limit_key].get_current_usage()[
Expand Down Expand Up @@ -191,10 +195,10 @@ def test_find_clusters_usage(self):
assert cls.limits[fargate_profiles_limit_key].get_current_usage()[
0].get_value() == 1
assert cls.limits[fargate_profiles_limit_key].get_current_usage()[
1].get_value() == 2
1].get_value() == 3

assert len(cls.limits[
selectors_limit_key].get_current_usage()) == 3
selectors_limit_key].get_current_usage()) == 4
assert cls.limits[selectors_limit_key].get_current_usage()[
0].get_value() == 1
assert cls.limits[selectors_limit_key].get_current_usage()[
Expand Down
2 changes: 1 addition & 1 deletion dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def run(self):
for line in fh.readlines():
line = line.strip()
if (
line == '------------------' and
line == '-' * len(expected) and
last_line == expected
):
have_ver = True
Expand Down
9 changes: 3 additions & 6 deletions docs/build_generated_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def limits_for_ec2():
regions still use the old per-instance-type limits. Please see the sections
for either :ref:`limits.ec2-standard` or :ref:`limits.ec2-nonvcpu` for
details.
""")
limit_info += '.. _limits.ec2-standard:\n\n'
limit_info += "EC2 - Standard Regions\n"
Expand All @@ -180,10 +180,10 @@ def limits_for_ec2():
(On-Demand, Reserved, etc.). The value that awslimitchecker reports
for Running On-Demand Instances current usage will *not* match the
number of instances you see in the Console or API.
**Important:** The limits for **Running On-Demand Instances** are now
measured in vCPU count per instance family, not instance count per instance
type.
type.
""") + "\n"
limit_info += "\n"
limit_info += format_limits_for_service(
Expand Down Expand Up @@ -299,9 +299,6 @@ def build_runner_examples():
'--limit="AutoScaling/Launch configurations"=456',
'-l',
],
'check_thresholds': ['awslimitchecker', '--no-color'],
'check_thresholds_custom': ['awslimitchecker', '-W', '97',
'--critical=98', '--no-color'],
'iam_policy': ['awslimitchecker', '--iam-policy'],
'list_metrics': ['awslimitchecker', '--list-metrics-providers'],
'list_alerts': ['awslimitchecker', '--list-alert-providers'],
Expand Down
8 changes: 8 additions & 0 deletions docs/source/awslimitchecker.services.eks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
awslimitchecker.services.eks module
===================================

.. automodule:: awslimitchecker.services.eks
:members:
:undoc-members:
:show-inheritance:
:private-members:
8 changes: 8 additions & 0 deletions docs/source/awslimitchecker.services.kinesis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
awslimitchecker.services.kinesis module
=======================================

.. automodule:: awslimitchecker.services.kinesis
:members:
:undoc-members:
:show-inheritance:
:private-members:
2 changes: 2 additions & 0 deletions docs/source/awslimitchecker.services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ Submodules
awslimitchecker.services.ec2
awslimitchecker.services.ecs
awslimitchecker.services.efs
awslimitchecker.services.eks
awslimitchecker.services.elasticache
awslimitchecker.services.elasticbeanstalk
awslimitchecker.services.elb
awslimitchecker.services.firehose
awslimitchecker.services.iam
awslimitchecker.services.kinesis
awslimitchecker.services.lambdafunc
awslimitchecker.services.rds
awslimitchecker.services.redshift
Expand Down
12 changes: 3 additions & 9 deletions docs/source/cli_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ threshold only, and another has crossed the critical threshold):
VPC/NAT Gateways per AZ (limit 5) CRITICAL: us-east-1d=5, us-east-1c= (...)
VPC/Virtual private gateways (limit 5) WARNING: 4
.. _cli_usage.threshold_overrides:

Set Custom Thresholds
Expand All @@ -482,8 +480,6 @@ To set the warning threshold of 50% and a critical threshold of 75% when checkin
S3/Buckets (limit 100) CRITICAL: 946
VPC/NAT Gateways per AZ (limit 5) CRITICAL: us-east-1d=5, us-east-1c= (...)
You can also set custom thresholds on a per-limit basis using the
``--threshold-override-json`` CLI option, which accepts the path to a JSON file
(local or an s3:// URL) matching the format described in
Expand Down Expand Up @@ -530,17 +526,15 @@ Using a command like:
.. code-block:: console
(venv)$ awslimitchecker -W 97 --critical=98 --no-color --threshold-override-json=s3://bucketname/path/overrides.json
DynamoDB/Local Secondary Indexes (limit 5) CRITICAL: some_app_name_here=5
DynamoDB/Local Secondary Indexes (limit 5) CRITICAL: some_app_name (...)
DynamoDB/Tables Per Region (limit 256) CRITICAL: 554
EC2/Rules per VPC security group (limit 50) CRITICAL: sg-aaaaaaaa=49, sg-bbbbb (...)
EC2/Security groups per VPC (limit 500) CRITICAL: vpc-cccccccc=726, vpc-c (...)
EC2/Rules per VPC security group (limit 50) CRITICAL: sg-cccccccc=49, sg-eeeee (...)
EC2/Security groups per VPC (limit 500) CRITICAL: vpc-dddddddd=726, vpc-c (...)
(...)
RDS/VPC Security Groups (limit 5) CRITICAL: 5
S3/Buckets (limit 100) CRITICAL: 946
VPC/NAT Gateways per AZ (limit 5) CRITICAL: us-east-1d=5, us-east-1c= (...)
.. _cli_usage.metrics:

Enable Metrics Provider
Expand Down
34 changes: 31 additions & 3 deletions docs/source/cli_usage.rst.template
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,18 @@ usage value, or both; this functionality is not currently present in the command
To check all limits against their thresholds (in this example, one limit has crossed the warning
threshold only, and another has crossed the critical threshold):

{check_thresholds}
.. code-block:: console

(venv)$ awslimitchecker --no-color
CloudFormation/Stacks (limit 4000) WARNING: 3396
DynamoDB/Local Secondary Indexes (limit 5) CRITICAL: some_app_name (...)
DynamoDB/Tables Per Region (limit 256) CRITICAL: 554
EBS/Active snapshots (limit 40000.0) WARNING: 33387
EC2/Rules per VPC security group (limit 50) CRITICAL: sg-aaaaaaaa=50, sg-bbbb (...)
(...)
VPC/Entries per route table (limit 50) WARNING: rtb-aaaaaaaa=43, rtb-bbbb (...)
VPC/NAT Gateways per AZ (limit 5) CRITICAL: us-east-1d=5, us-east-1c= (...)
VPC/Virtual private gateways (limit 5) WARNING: 4

.. _cli_usage.threshold_overrides:

Expand All @@ -196,7 +207,17 @@ Set Custom Thresholds

To set the warning threshold of 50% and a critical threshold of 75% when checking limits:

{check_thresholds_custom}
.. code-block:: console

(venv)$ awslimitchecker -W 97 --critical=98 --no-color
DynamoDB/Local Secondary Indexes (limit 5) CRITICAL: some_app_name (...)
DynamoDB/Tables Per Region (limit 256) CRITICAL: 554
EC2/Rules per VPC security group (limit 50) CRITICAL: sg-cccccccc=49, sg-eeeee (...)
EC2/Security groups per VPC (limit 500) CRITICAL: vpc-dddddddd=726, vpc-c (...)
(...)
RDS/VPC Security Groups (limit 5) CRITICAL: 5
S3/Buckets (limit 100) CRITICAL: 946
VPC/NAT Gateways per AZ (limit 5) CRITICAL: us-east-1d=5, us-east-1c= (...)

You can also set custom thresholds on a per-limit basis using the
``--threshold-override-json`` CLI option, which accepts the path to a JSON file
Expand All @@ -212,7 +233,14 @@ Using a command like:
.. code-block:: console

(venv)$ awslimitchecker -W 97 --critical=98 --no-color --threshold-override-json=s3://bucketname/path/overrides.json
{check_thresholds_custom-output-only}
DynamoDB/Local Secondary Indexes (limit 5) CRITICAL: some_app_name (...)
DynamoDB/Tables Per Region (limit 256) CRITICAL: 554
EC2/Rules per VPC security group (limit 50) CRITICAL: sg-cccccccc=49, sg-eeeee (...)
EC2/Security groups per VPC (limit 500) CRITICAL: vpc-dddddddd=726, vpc-c (...)
(...)
RDS/VPC Security Groups (limit 5) CRITICAL: 5
S3/Buckets (limit 100) CRITICAL: 946
VPC/NAT Gateways per AZ (limit 5) CRITICAL: us-east-1d=5, us-east-1c= (...)

.. _cli_usage.metrics:

Expand Down
6 changes: 6 additions & 0 deletions docs/source/iam_policy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ services that do not affect the results of this program.
"ecs:DescribeServices",
"ecs:ListClusters",
"ecs:ListServices",
"eks:DescribeCluster",
"eks:DescribeFargateProfile",
"eks:ListClusters",
"eks:ListFargateProfiles",
"eks:ListNodegroups",
"elasticache:DescribeCacheClusters",
"elasticache:DescribeCacheParameterGroups",
"elasticache:DescribeCacheSecurityGroups",
Expand All @@ -86,6 +91,7 @@ services that do not affect the results of this program.
"elasticloadbalancing:DescribeTargetGroups",
"firehose:ListDeliveryStreams",
"iam:GetAccountSummary",
"kinesis:DescribeLimits",
"lambda:GetAccountSettings",
"rds:DescribeAccountAttributes",
"rds:DescribeDBInstances",
Expand Down

0 comments on commit b6b2e84

Please sign in to comment.