Skip to content

Commit

Permalink
fix default GPU quota and update tests
Browse files Browse the repository at this point in the history
The default GPU quota multiplier should have been 0 given that we don't
want a user to have access to a GPU until they explicitly request one
via coldfront. Also updated the tests to include requesting an OpenShift
GPU.
  • Loading branch information
jtriley committed Nov 27, 2023
1 parent e4c2aaa commit f4000db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/coldfront_plugin_cloud/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
attributes.QUOTA_LIMITS_MEMORY: 4096,
attributes.QUOTA_LIMITS_EPHEMERAL_STORAGE_GB: 5,
attributes.QUOTA_REQUESTS_STORAGE: 20,
attributes.QUOTA_REQUESTS_GPU: 1,
attributes.QUOTA_REQUESTS_GPU: 0,
attributes.QUOTA_PVC: 2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def test_new_allocation_quota(self):
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 * 20)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_REQUESTS_GPU), 2 * 0)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_PVC), 2 * 2)

quota = allocator.get_quota(project_id)['Quota']
Expand All @@ -131,6 +132,7 @@ def test_new_allocation_quota(self):
":limits.memory": "8Gi",
":limits.ephemeral-storage": "10Gi",
":requests.storage": "40Gi",
":requests.nvidia.com/gpu": "0",
":persistentvolumeclaims": "4",
})

Expand All @@ -139,12 +141,14 @@ def test_new_allocation_quota(self):
utils.set_attribute_on_allocation(allocation, attributes.QUOTA_LIMITS_MEMORY, 8192)
utils.set_attribute_on_allocation(allocation, attributes.QUOTA_LIMITS_EPHEMERAL_STORAGE_GB, 50)
utils.set_attribute_on_allocation(allocation, attributes.QUOTA_REQUESTS_STORAGE, 100)
utils.set_attribute_on_allocation(allocation, attributes.QUOTA_REQUESTS_GPU, 1)
utils.set_attribute_on_allocation(allocation, attributes.QUOTA_PVC, 10)

self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_CPU), 6)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_MEMORY), 8192)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_LIMITS_EPHEMERAL_STORAGE_GB), 50)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_REQUESTS_STORAGE), 100)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_REQUESTS_GPU), 1)
self.assertEqual(allocation.get_attribute(attributes.QUOTA_PVC), 10)

# This call should update the openshift quota to match the current attributes
Expand All @@ -158,6 +162,7 @@ def test_new_allocation_quota(self):
":limits.memory": "8Gi",
":limits.ephemeral-storage": "50Gi",
":requests.storage": "100Gi",
":requests.nvidia.com/gpu": "1",
":persistentvolumeclaims": "10",
})

Expand Down Expand Up @@ -186,6 +191,7 @@ def test_reactivate_allocation(self):
":limits.memory": "8Gi",
":limits.ephemeral-storage": "10Gi",
":requests.storage": "40Gi",
":requests.nvidia.com/gpu": "0",
":persistentvolumeclaims": "4",
})

Expand All @@ -204,6 +210,7 @@ def test_reactivate_allocation(self):
":limits.memory": "8Gi",
":limits.ephemeral-storage": "10Gi",
":requests.storage": "40Gi",
":requests.nvidia.com/gpu": "0",
":persistentvolumeclaims": "4",
})

Expand Down

0 comments on commit f4000db

Please sign in to comment.