account_quotas: Fix X-Remove-Account-Quota-Bytes-Policy-<name>
Previously, this would reduce the account's quota to zero, which seems like the opposite of what the operator intended. Now, remove the quota, similar to sending an empty quota header. Change-Id: Ic28752d835e0b970f2baa4e68cbfcde4f500b3d4
This commit is contained in:
parent
cd288b183d
commit
cd0fe25da1
@ -98,12 +98,12 @@ class AccountQuotaMiddleware(object):
|
||||
'X-Account-Meta-%s' % quota_type)
|
||||
if request.headers.get(
|
||||
'X-Remove-Account-Meta-%s' % quota_type):
|
||||
new_quotas[None] = 0 # X-Remove dominates if both are present
|
||||
new_quotas[None] = '' # X-Remove dominates if both are present
|
||||
|
||||
for policy in POLICIES:
|
||||
tail = 'Account-%s-Policy-%s' % (quota_type, policy.name)
|
||||
if request.headers.get('X-Remove-' + tail):
|
||||
new_quotas[policy.idx] = 0
|
||||
new_quotas[policy.idx] = ''
|
||||
else:
|
||||
quota = request.headers.pop('X-' + tail, None)
|
||||
new_quotas[policy.idx] = quota
|
||||
|
@ -1035,13 +1035,12 @@ class TestAccountQuotas(unittest.TestCase):
|
||||
|
||||
self._check_admin_can_post(
|
||||
{quota_header.replace('X-', 'X-Remove-'): 't'})
|
||||
# TODO: well that seems like the opposite of what was intended...
|
||||
self.assertEqual('0', get_current_quota())
|
||||
self.assertIsNone(get_current_quota())
|
||||
|
||||
self._check_admin_can_post({quota_header: '111'})
|
||||
self.assertEqual('111', get_current_quota())
|
||||
|
||||
# Can actually remove with an explicit empty string
|
||||
# Can also remove with an explicit empty string
|
||||
self._check_admin_can_post({quota_header: ''})
|
||||
self.assertIsNone(get_current_quota())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user