Give proper ERROR for too large exports

The "api_export_size" quota is currently being
enforced, but it doesn't give a proper ERROR on
the "export" resource. This is due to some bad
exception handling.

Change-Id: Ic27c781a35ea74ba605c05275f6970b44b07b65e
closes-bug: 1566911
This commit is contained in:
Tim Simmons 2016-04-06 15:57:18 +01:00
parent 1a3b28610a
commit debbe73dbf
2 changed files with 21 additions and 1 deletions

View File

@ -20,6 +20,7 @@
import mock
from oslotest import base as test
from designate import exceptions
from designate.tests.unit import RoObject
import designate.zone_manager.service as zms
@ -79,3 +80,22 @@ class ZoneManagerTest(test.BaseTestCase):
},
out
)
def test_exceed_size_quota(self, _):
context = mock.Mock()
export = dict(location=None, id=4)
size = 9999999999
self.tm.quota.limit_check.side_effect = exceptions.OverQuota()
out = self.tm._determine_export_method(context, export, size)
self.tm.quota.limit_check.side_effect = None
self.assertDictEqual(
{
'status': 'ERROR',
'id': 4,
'location': None,
'message': 'Zone is too large to export'
},
out
)

View File

@ -125,7 +125,7 @@ class Service(service.RPCService, coordination.CoordinationMixin,
try:
self.quota.limit_check(
context, context.tenant, api_export_size=size)
except exceptions.OverQuota():
except exceptions.OverQuota:
LOG.debug('Zone Export too large to perform synchronously')
export['status'] = 'ERROR'
export['message'] = 'Zone is too large to export'