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

updated the new default value for 1 Unit of resource allocation #119

Merged
merged 4 commits into from
Nov 7, 2023
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
10 changes: 5 additions & 5 deletions src/coldfront_plugin_cloud/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
UNIT_QUOTA_MULTIPLIERS = {
'openstack': {
attributes.QUOTA_INSTANCES: 1,
attributes.QUOTA_VCPU: 2,
attributes.QUOTA_VCPU: 1,
attributes.QUOTA_RAM: 4096,
attributes.QUOTA_VOLUMES: 2,
attributes.QUOTA_VOLUMES_GB: 100,
attributes.QUOTA_VOLUMES_GB: 20,
attributes.QUOTA_FLOATING_IPS: 0,
attributes.QUOTA_OBJECT_GB: 1,
attributes.QUOTA_GPU: 0,
},
'openshift': {
attributes.QUOTA_LIMITS_CPU: 2,
attributes.QUOTA_LIMITS_MEMORY: 2048,
attributes.QUOTA_LIMITS_CPU: 1,
attributes.QUOTA_LIMITS_MEMORY: 4096,
attributes.QUOTA_LIMITS_EPHEMERAL_STORAGE_GB: 5,
attributes.QUOTA_REQUESTS_STORAGE: 10,
attributes.QUOTA_REQUESTS_STORAGE: 20,
attributes.QUOTA_PVC: 2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ def test_new_allocation_quota(self):

project_id = allocation.get_attribute(attributes.ALLOCATION_PROJECT_ID)

self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_CPU), 2 * 2)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_MEMORY), 2 * 2048)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_CPU), 2 * 1)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_MEMORY), 2 * 4096)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_EPHEMERAL_STORAGE_GB), 2 * 5)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_REQUESTS_STORAGE), 2 * 10)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_REQUESTS_STORAGE), 2 * 20)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_PVC), 2 * 2)

quota = allocator.get_quota(project_id)['Quota']
quota = {k: v for k, v in quota.items() if v is not None}
# The return value will update to the most relevant unit, so
# 4000m cores becomes 4 and 4096Mi becomes 4Gi
# 2000m cores becomes 2 and 8192Mi becomes 8Gi
self.assertEqual(quota, {
":limits.cpu": "4",
":limits.memory": "4Gi",
":limits.cpu": "2",
":limits.memory": "8Gi",
":limits.ephemeral-storage": "10Gi",
":requests.storage": "20Gi",
":requests.storage": "40Gi",
":persistentvolumeclaims": "4",
})

Expand Down Expand Up @@ -173,19 +173,19 @@ def test_reactivate_allocation(self):

project_id = allocation.get_attribute(attributes.ALLOCATION_PROJECT_ID)

self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_CPU), 4)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_CPU), 2)

quota = allocator.get_quota(project_id)['Quota']

# https://github.com/CCI-MOC/openshift-acct-mgt
quota = {k: v for k, v in quota.items() if v is not None}
# The return value will update to the most relevant unit, so
# 4000m cores becomes 4 and 4096Mi becomes 4Gi
# 2000m cores becomes 2 and 8192Mi becomes 8Gi
self.assertEqual(quota, {
":limits.cpu": "4",
":limits.memory": "4Gi",
":limits.cpu": "2",
":limits.memory": "8Gi",
":limits.ephemeral-storage": "10Gi",
":requests.storage": "20Gi",
":requests.storage": "40Gi",
":persistentvolumeclaims": "4",
})

Expand All @@ -198,12 +198,12 @@ def test_reactivate_allocation(self):
quota = allocator.get_quota(project_id)['Quota']
quota = {k: v for k, v in quota.items() if v is not None}
# The return value will update to the most relevant unit, so
# 4000m cores becomes 4 and 4096Mi becomes 4Gi
# 3000m cores becomes 3 and 8192Mi becomes 8Gi
self.assertEqual(quota, {
":limits.cpu": "3",
":limits.memory": "4Gi",
":limits.memory": "8Gi",
":limits.ephemeral-storage": "10Gi",
":requests.storage": "20Gi",
":requests.storage": "40Gi",
":persistentvolumeclaims": "4",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_new_allocation(self):
# Check nova quota
expected_nova_quota = {
'instances': 1,
'cores': 2,
'cores': 1,
'ram': 4096,
}
actual_nova_quota = self.compute.quotas.get(openstack_project.id)
Expand All @@ -78,7 +78,7 @@ def test_new_allocation(self):
# Check cinder quota
expected_cinder_quota = {
'volumes': 2,
'gigabytes': 100,
'gigabytes': 20,
}
actual_cinder_quota = self.volume.quotas.get(openstack_project.id)
for k, v in expected_cinder_quota.items():
Expand All @@ -95,10 +95,10 @@ def test_new_allocation(self):
# Validate get_quota
expected_quota = {
'instances': 1,
'cores': 2,
'cores': 1,
'ram': 4096,
'volumes': 2,
'gigabytes': 100,
'gigabytes': 20,
'floatingip': 2,
'x-account-meta-quota-bytes': 1,
}
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_new_allocation_with_quantity(self):
# Check nova quota
expected_nova_quota = {
'instances': 1 * 3,
'cores': 2 * 3,
'cores': 1 * 3,
'ram': 4096 * 3,
}
actual_nova_quota = self.compute.quotas.get(openstack_project.id)
Expand All @@ -154,7 +154,7 @@ def test_new_allocation_with_quantity(self):
# Check cinder quota
expected_cinder_quota = {
'volumes': 2 * 3,
'gigabytes': 100 * 3,
'gigabytes': 20 * 3,
}
actual_cinder_quota = self.volume.quotas.get(openstack_project.id)
for k, v in expected_cinder_quota.items():
Expand All @@ -170,7 +170,7 @@ def test_new_allocation_with_quantity(self):

# Change allocation attribute for floating ips and cores
self.assertEqual(allocation.get_attribute(attributes.QUOTA_FLOATING_IPS), 2)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_VCPU), 2 * 3)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_VCPU), 1 * 3)
utils.set_attribute_on_allocation(allocation, attributes.QUOTA_FLOATING_IPS, 3)
utils.set_attribute_on_allocation(allocation, attributes.QUOTA_VCPU, 100)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_FLOATING_IPS), 3)
Expand Down
Loading