Skip to content

Commit

Permalink
Merge pull request #523 from andyjp/ebs-io2
Browse files Browse the repository at this point in the history
Ebs io2
  • Loading branch information
jantman committed Apr 20, 2021
2 parents ef22d43 + 237f430 commit 608e087
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ include/
*.iml
.idea/

# VSCode
.vscode

dev/.terraform
dev/iam_policy.json
dev/terraform.tfstate.backup
Expand Down
65 changes: 51 additions & 14 deletions awslimitchecker/services/ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ def find_usage(self):
def _find_usage_ebs(self):
"""calculate usage for all EBS limits and update Limits"""
vols = 0
piops = 0
piops_gb = 0
piops_io1 = 0
piops_io1_gb = 0
piops_io2 = 0
piops_io2_gb = 0
gp2_gb = 0
gp3_gb = 0
mag_gb = 0
Expand All @@ -98,8 +100,11 @@ def _find_usage_ebs(self):
for vol in results['Volumes']:
vols += 1
if vol['VolumeType'] == 'io1':
piops_gb += vol['Size']
piops += vol['Iops']
piops_io1_gb += vol['Size']
piops_io1 += vol['Iops']
elif vol['VolumeType'] == 'io2':
piops_io2_gb += vol['Size']
piops_io2 += vol['Iops']
elif vol['VolumeType'] == 'gp2':
gp2_gb += vol['Size']
elif vol['VolumeType'] == 'gp3':
Expand All @@ -116,14 +121,24 @@ def _find_usage_ebs(self):
" not counting",
vol['VolumeType'],
vol['VolumeId'])
self.limits['Provisioned IOPS']._add_current_usage(
piops,
self.limits['Provisioned IOPS (io1)']._add_current_usage(
piops_io1,
aws_type='AWS::EC2::Volume'
)
self.limits[
'Provisioned IOPS (SSD) storage (GiB)'
'Provisioned IOPS SSD (io1) storage (GiB)'
]._add_current_usage(
piops_gb,
piops_io1_gb,
aws_type='AWS::EC2::Volume'
)
self.limits['Provisioned IOPS (io2)']._add_current_usage(
piops_io2,
aws_type='AWS::EC2::Volume'
)
self.limits[
'Provisioned IOPS SSD (io2) storage (GiB)'
]._add_current_usage(
piops_io2_gb,
aws_type='AWS::EC2::Volume'
)
self.limits[
Expand Down Expand Up @@ -200,18 +215,18 @@ def _get_limits_ebs(self):
:rtype: dict
"""
limits = {}
limits['Provisioned IOPS'] = AwsLimit(
'Provisioned IOPS',
limits['Provisioned IOPS (io1)'] = AwsLimit(
'Provisioned IOPS (io1)',
self,
200000,
300000,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::EC2::Volume',
limit_subtype='io1',
quotas_name='Provisioned IOPS'
quotas_name='Provisioned IOPS (io1)'
)
limits['Provisioned IOPS (SSD) storage (GiB)'] = AwsLimit(
'Provisioned IOPS (SSD) storage (GiB)',
limits['Provisioned IOPS SSD (io1) storage (GiB)'] = AwsLimit(
'Provisioned IOPS SSD (io1) storage (GiB)',
self,
307200,
self.warning_threshold,
Expand All @@ -222,6 +237,28 @@ def _get_limits_ebs(self):
quotas_unit='GiB',
quotas_unit_converter=convert_TiB_to_GiB
)
limits['Provisioned IOPS (io2)'] = AwsLimit(
'Provisioned IOPS (io2)',
self,
100000,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::EC2::Volume',
limit_subtype='io2',
quotas_name='Provisioned IOPS (io2)'
)
limits['Provisioned IOPS SSD (io2) storage (GiB)'] = AwsLimit(
'Provisioned IOPS SSD (io2) storage (GiB)',
self,
20480,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::EC2::Volume',
limit_subtype='io2',
quotas_name='Provisioned IOPS SSD (io2) volume storage',
quotas_unit='GiB',
quotas_unit_converter=convert_TiB_to_GiB
)
limits['General Purpose (SSD gp2) volume storage (GiB)'] = AwsLimit(
'General Purpose (SSD gp2) volume storage (GiB)',
self,
Expand Down
14 changes: 14 additions & 0 deletions awslimitchecker/tests/services/result_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ class EBS(object):
'VolumeType': 'io1',
'Iops': 300,
},
# 400G PIOPS, 700 IOPS
{
'VolumeId': 'vol-5',
'Size': 400,
'VolumeType': 'io2',
'Iops': 700,
},
# 100G PIOPS, 300 IOPS
{
'VolumeId': 'vol-6',
'Size': 100,
'VolumeType': 'io2',
'Iops': 300,
},
# othertype
{
'VolumeId': 'vol-7',
Expand Down
45 changes: 31 additions & 14 deletions awslimitchecker/tests/services/test_ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,23 @@ def test_get_limits(self):
assert isinstance(limits[x], AwsLimit)
assert x == limits[x].name
assert limits[x].service == cls
assert len(limits) == 9
piops = limits['Provisioned IOPS']
assert piops.limit_type == 'AWS::EC2::Volume'
assert piops.limit_subtype == 'io1'
assert piops.default_limit == 200000
piops_tb = limits['Provisioned IOPS (SSD) storage (GiB)']
assert piops_tb.limit_type == 'AWS::EC2::Volume'
assert piops_tb.limit_subtype == 'io1'
assert piops_tb.default_limit == 307200
assert len(limits) == 11
piops_io1 = limits['Provisioned IOPS (io1)']
assert piops_io1.limit_type == 'AWS::EC2::Volume'
assert piops_io1.limit_subtype == 'io1'
assert piops_io1.default_limit == 300000
piops_io1_tb = limits['Provisioned IOPS SSD (io1) storage (GiB)']
assert piops_io1_tb.limit_type == 'AWS::EC2::Volume'
assert piops_io1_tb.limit_subtype == 'io1'
assert piops_io1_tb.default_limit == 307200
piops_io2 = limits['Provisioned IOPS (io2)']
assert piops_io2.limit_type == 'AWS::EC2::Volume'
assert piops_io2.limit_subtype == 'io2'
assert piops_io2.default_limit == 100000
piops_io2_tb = limits['Provisioned IOPS SSD (io2) storage (GiB)']
assert piops_io2_tb.limit_type == 'AWS::EC2::Volume'
assert piops_io2_tb.limit_subtype == 'io2'
assert piops_io2_tb.default_limit == 20480
gp2_tb = limits['General Purpose (SSD gp2) volume storage (GiB)']
assert gp2_tb.limit_type == 'AWS::EC2::Volume'
assert gp2_tb.limit_subtype == 'gp2'
Expand Down Expand Up @@ -164,12 +172,21 @@ def test_find_usage_ebs(self):
"ERROR - unknown volume type '%s' for volume "
"%s; not counting", 'othertype', 'vol-7')
]
assert len(cls.limits['Provisioned IOPS'].get_current_usage()) == 1
assert cls.limits['Provisioned IOPS'
assert len(cls.limits['Provisioned IOPS (io1)'
''].get_current_usage()) == 1
assert cls.limits['Provisioned IOPS (io1)'
''].get_current_usage()[0].get_value() == 1000
assert len(cls.limits['Provisioned IOPS (SSD) storage '
assert len(cls.limits['Provisioned IOPS SSD (io1) storage '
'(GiB)'].get_current_usage()) == 1
assert cls.limits['Provisioned IOPS (SSD) storage '
assert cls.limits['Provisioned IOPS SSD (io1) storage '
'(GiB)'].get_current_usage()[0].get_value() == 500
assert len(cls.limits['Provisioned IOPS (io2)'
''].get_current_usage()) == 1
assert cls.limits['Provisioned IOPS (io2)'
''].get_current_usage()[0].get_value() == 1000
assert len(cls.limits['Provisioned IOPS SSD (io2) storage '
'(GiB)'].get_current_usage()) == 1
assert cls.limits['Provisioned IOPS SSD (io2) storage '
'(GiB)'].get_current_usage()[0].get_value() == 500
assert len(cls.limits['General Purpose (SSD gp2) volume storage '
'(GiB)'].get_current_usage()) == 1
Expand All @@ -194,7 +211,7 @@ def test_find_usage_ebs(self):

assert len(cls.limits['Active volumes'].get_current_usage()) == 1
assert cls.limits['Active volumes'
''].get_current_usage()[0].get_value() == 11
''].get_current_usage()[0].get_value() == 13
assert mock_conn.mock_calls == []
assert mock_paginate.mock_calls == [
call(
Expand Down

0 comments on commit 608e087

Please sign in to comment.