Skip to content

Commit

Permalink
Fixed bug for billing with change requests
Browse files Browse the repository at this point in the history
Due to an boolean statement, the SU hours for storage will not
be correctly calculated when change requests (CRs) to quotas are involved.

Our intention with CRs is that when an allocation's storage quota
decreases, this decreased value becomes effective (for billing purposes)
when the CR for it is created, not when the CR is
approved (or the time at which the quota actually decreased).
The aforementioned boolean statement would instead lead to undesired behavior.
  • Loading branch information
QuanMPhm authored and knikolla committed Aug 1, 2024
1 parent 3bc63e5 commit e523675
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def test_new_allocation_quota_never_approved(self):
)
self.assertEqual(value, 0)

@unittest.expectedFailure
def test_change_request_decrease(self):
"""Test for when a change request decreases the quota"""
self.resource = self.new_openshift_resource(
Expand Down Expand Up @@ -267,7 +266,6 @@ def test_change_request_increase(self):
)
self.assertEqual(value, 384)

@unittest.expectedFailure
def test_change_request_decrease_multiple(self):
"""Test for when multiple different change request decreases the quota"""
self.resource = self.new_openshift_resource(
Expand Down
2 changes: 1 addition & 1 deletion src/coldfront_plugin_cloud/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def calculate_quota_unit_hours(allocation: Allocation,
# find one that happened just before the next event.
cr_created_at = cr.history.first().created
if cr.history.first().created <= event_time:
if unbounded_last_event_time and unbounded_last_event_time < cr_created_at:
if unbounded_last_event_time and unbounded_last_event_time > cr_created_at:
# But after the unbounded last event time.
continue

Expand Down

0 comments on commit e523675

Please sign in to comment.