Commit b63b06d5 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Pithos: handle quotaholder exception errors

parent f00a7a6b
......@@ -979,8 +979,8 @@ def object_write(request, v_account, v_container, v_object):
raise ItemNotFound('Container does not exist')
except ValueError:
raise BadRequest('Invalid sharing header')
except QuotaError:
raise RequestEntityTooLarge('Quota exceeded')
except QuotaError, e:
raise RequestEntityTooLarge('Quota error: %s' % e)
if not checksum and UPDATE_MD5:
# Update the MD5 after the hashmap, as there may be missing hashes.
checksum = hashmap_md5(request.backend, hashmap, size)
......@@ -1027,8 +1027,8 @@ def object_write_form(request, v_account, v_container, v_object):
raise Forbidden('Not allowed')
except ItemNotExists:
raise ItemNotFound('Container does not exist')
except QuotaError:
raise RequestEntityTooLarge('Quota exceeded')
except QuotaError, e:
raise RequestEntityTooLarge('Quota error: %s' % e)
response = HttpResponse(status=201)
response['ETag'] = checksum
......@@ -1312,8 +1312,8 @@ def object_update(request, v_account, v_container, v_object):
raise ItemNotFound('Container does not exist')
except ValueError:
raise BadRequest('Invalid sharing header')
except QuotaError:
raise RequestEntityTooLarge('Quota exceeded')
except QuotaError, e:
raise RequestEntityTooLarge('Quota error: %s' % e)
if public is not None:
try:
request.backend.update_object_public(request.user_uniq, v_account,
......
......@@ -853,10 +853,9 @@ class ModularBackend(BaseBackend):
account_quota = long(self._get_policy(account_node)['quota'])
account_usage = self._get_statistics(account_node)[1] + size_delta
if (account_quota > 0 and account_usage > account_quota):
logger.error('account_quota: %s, account_usage: %s' % (
raise QuotaError('account quota exceeded: limit: %s, usage: %s' % (
account_quota, account_usage
))
raise QuotaError
# Check container quota.
container_quota = long(self._get_policy(container_node)['quota'])
......@@ -864,10 +863,9 @@ class ModularBackend(BaseBackend):
if (container_quota > 0 and container_usage > container_quota):
# This must be executed in a transaction, so the version is
# never created if it fails.
logger.error('container_quota: %s, container_usage: %s' % (
raise QuotaError('container quota exceeded: limit: %s, usage: %s' % (
container_quota, container_usage
))
raise QuotaError
self._report_size_change(user, account, size_delta,
{'action': 'object update', 'path': path,
......@@ -1292,16 +1290,20 @@ class ModularBackend(BaseBackend):
if not self.using_external_quotaholder:
return
serial = self.quotaholder.issue_commission(
context = {},
target = account,
key = '1',
clientkey = 'pithos',
ownerkey = '',
name = details['path'] if 'path' in details else '',
provisions = (('pithos+', 'pithos+.diskspace', size),)
)
self.serials.append(serial)
try:
serial = self.quotaholder.issue_commission(
context = {},
target = account,
key = '1',
clientkey = 'pithos',
ownerkey = '',
name = details['path'] if 'path' in details else '',
provisions = (('pithos+', 'pithos+.diskspace', size),)
)
except BaseException, e:
raise QuotaError(e)
else:
self.serials.append(serial)
def _report_object_change(self, user, account, path, details={}):
details.update({'user': user})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment