Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gp3 ebs type #519

Merged
merged 9 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions awslimitchecker/services/ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def _find_usage_ebs(self):
vols = 0
piops = 0
piops_gb = 0
gp_gb = 0
gp2_gb = 0
gp3_gb = 0
mag_gb = 0
st_gb = 0
sc_gb = 0
Expand All @@ -100,7 +101,9 @@ def _find_usage_ebs(self):
piops_gb += vol['Size']
piops += vol['Iops']
elif vol['VolumeType'] == 'gp2':
gp_gb += vol['Size']
gp2_gb += vol['Size']
elif vol['VolumeType'] == 'gp3':
gp3_gb += vol['Size']
elif vol['VolumeType'] == 'standard':
mag_gb += vol['Size']
elif vol['VolumeType'] == 'st1':
Expand All @@ -124,9 +127,15 @@ def _find_usage_ebs(self):
aws_type='AWS::EC2::Volume'
)
self.limits[
'General Purpose (SSD) volume storage (GiB)'
'General Purpose (SSD gp2) volume storage (GiB)'
]._add_current_usage(
gp_gb,
gp2_gb,
aws_type='AWS::EC2::Volume'
)
self.limits[
'General Purpose (SSD gp3) volume storage (GiB)'
]._add_current_usage(
gp3_gb,
aws_type='AWS::EC2::Volume'
)
self.limits[
Expand Down Expand Up @@ -213,16 +222,29 @@ def _get_limits_ebs(self):
quotas_unit='GiB',
quotas_unit_converter=convert_TiB_to_GiB
)
limits['General Purpose (SSD) volume storage (GiB)'] = AwsLimit(
'General Purpose (SSD) volume storage (GiB)',
limits['General Purpose (SSD gp2) volume storage (GiB)'] = AwsLimit(
'General Purpose (SSD gp2) volume storage (GiB)',
self,
307200,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::EC2::Volume',
limit_subtype='gp2',
ta_limit_name='General Purpose SSD (gp2) volume storage (GiB)',
quotas_name='General Purpose (SSD) volume storage',
quotas_name='Storage for General Purpose SSD (gp2) volumes',
quotas_unit='GiB',
quotas_unit_converter=convert_TiB_to_GiB
)
limits['General Purpose (SSD gp3) volume storage (GiB)'] = AwsLimit(
'General Purpose (SSD gp3) volume storage (GiB)',
self,
307200,
self.warning_threshold,
self.critical_threshold,
limit_type='AWS::EC2::Volume',
limit_subtype='gp3',
ta_limit_name='General Purpose SSD (gp3) volume storage (GiB)',
quotas_name='Storage for General Purpose SSD (gp3) volumes',
quotas_unit='GiB',
quotas_unit_converter=convert_TiB_to_GiB
)
Expand Down
18 changes: 16 additions & 2 deletions awslimitchecker/tests/services/result_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ class EBS(object):
'VolumeType': 'standard',
'Iops': None,
},
# 15G general purpose SSD, 45 IOPS
# 15G general purpose SSD gp2, 45 IOPS
{
'VolumeId': 'vol-3',
'Size': 15,
'VolumeType': 'gp2',
'Iops': 45,
},
# 30G general purpose SSD, 90 IOPS
# 30G general purpose SSD gp2, 90 IOPS
{
'VolumeId': 'vol-4',
'Size': 30,
Expand Down Expand Up @@ -188,6 +188,20 @@ class EBS(object):
'VolumeType': 'sc1',
'Iops': None,
},
# 10G general purpose SSD gp3, 30 IOPS
{
'VolumeId': 'vol-3',
'Size': 10,
'VolumeType': 'gp3',
'Iops': 30,
},
# 30G general purpose SSD gp3, 90 IOPS
{
'VolumeId': 'vol-4',
'Size': 30,
'VolumeType': 'gp3',
'Iops': 90,
},
]
}

Expand Down
30 changes: 20 additions & 10 deletions awslimitchecker/tests/services/test_ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_get_limits(self):
assert isinstance(limits[x], AwsLimit)
assert x == limits[x].name
assert limits[x].service == cls
assert len(limits) == 8
assert len(limits) == 9
piops = limits['Provisioned IOPS']
assert piops.limit_type == 'AWS::EC2::Volume'
assert piops.limit_subtype == 'io1'
Expand All @@ -101,12 +101,18 @@ def test_get_limits(self):
assert piops_tb.limit_type == 'AWS::EC2::Volume'
assert piops_tb.limit_subtype == 'io1'
assert piops_tb.default_limit == 307200
gp_tb = limits['General Purpose (SSD) volume storage (GiB)']
assert gp_tb.limit_type == 'AWS::EC2::Volume'
assert gp_tb.limit_subtype == 'gp2'
assert gp_tb.default_limit == 307200
assert gp_tb.ta_limit_name == 'General Purpose SSD (gp2) ' \
'volume storage (GiB)'
gp2_tb = limits['General Purpose (SSD gp2) volume storage (GiB)']
assert gp2_tb.limit_type == 'AWS::EC2::Volume'
assert gp2_tb.limit_subtype == 'gp2'
assert gp2_tb.default_limit == 307200
assert gp2_tb.ta_limit_name == 'General Purpose SSD (gp2) ' \
'volume storage (GiB)'
gp3_tb = limits['General Purpose (SSD gp3) volume storage (GiB)']
assert gp3_tb.limit_type == 'AWS::EC2::Volume'
assert gp3_tb.limit_subtype == 'gp3'
assert gp3_tb.default_limit == 307200
assert gp3_tb.ta_limit_name == 'General Purpose SSD (gp3) ' \
'volume storage (GiB)'
mag_tb = limits['Magnetic volume storage (GiB)']
assert mag_tb.limit_type == 'AWS::EC2::Volume'
assert mag_tb.limit_subtype == 'standard'
Expand Down Expand Up @@ -165,10 +171,14 @@ def test_find_usage_ebs(self):
'(GiB)'].get_current_usage()) == 1
assert cls.limits['Provisioned IOPS (SSD) storage '
'(GiB)'].get_current_usage()[0].get_value() == 500
assert len(cls.limits['General Purpose (SSD) volume storage '
assert len(cls.limits['General Purpose (SSD gp2) volume storage '
'(GiB)'].get_current_usage()) == 1
assert cls.limits['General Purpose (SSD) volume storage '
assert cls.limits['General Purpose (SSD gp2) volume storage '
'(GiB)'].get_current_usage()[0].get_value() == 45
assert len(cls.limits['General Purpose (SSD gp3) volume storage '
'(GiB)'].get_current_usage()) == 1
assert cls.limits['General Purpose (SSD gp3) volume storage '
'(GiB)'].get_current_usage()[0].get_value() == 40
assert len(cls.limits['Magnetic volume storage '
'(GiB)'].get_current_usage()) == 1
assert cls.limits['Magnetic volume storage '
Expand All @@ -184,7 +194,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() == 9
''].get_current_usage()[0].get_value() == 11
assert mock_conn.mock_calls == []
assert mock_paginate.mock_calls == [
call(
Expand Down