Add try catch exception for plan destory before quota reserve

Change-Id: I6004b3705e5f7488e897154452a24af8694f38b6
Implements: blueprint support-quotas-in-karbor
This commit is contained in:
chenying 2017-11-06 15:08:07 +08:00
parent f843083007
commit 10de69e32d
1 changed files with 8 additions and 3 deletions

View File

@ -157,16 +157,21 @@ class PlansController(wsgi.Controller):
context.can(plan_policy.DELETE_POLICY, target_obj=plan)
project_id = plan.project_id
try:
plan.destroy()
except Exception:
msg = _("Failed to destroy a plan.")
raise exc.HTTPServerError(reason=msg)
try:
reserve_opts = {'plans': -1}
reservations = QUOTAS.reserve(context,
project_id=project_id,
**reserve_opts)
except Exception:
reservations = None
LOG.exception("Failed to update usages deleting plan.")
plan.destroy()
if reservations:
else:
QUOTAS.commit(context, reservations,
project_id=project_id)
LOG.info("Delete plan request issued successfully.",