Commit 8101def7 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

cyclades: Do not release resources if already deleted

Ensure that a commission to release vm resources is issued only once.
If a vm is marked `deleted', then resources must have already been
released.
parent 31d98e59
......@@ -407,9 +407,11 @@ def do_create_server(userid, name, password, flavor, image, metadata={},
# already reserved quotas by issuing a negative commission
vm.operstate = "ERROR"
vm.backendlogmsg = "Can not communicate to backend."
already_deleted = vm.deleted
vm.deleted = True
vm.save()
quotas.issue_and_accept_commission(vm, delete=True)
if not already_deleted:
quotas.issue_and_accept_commission(vm, delete=True)
raise
except:
transaction.rollback()
......
# Copyright 2011 GRNET S.A. All rights reserved.
# Copyright 2011-2013 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
......@@ -93,11 +93,13 @@ def process_op_status(vm, etime, jobid, opcode, status, logmsg, nics=None):
if status == "success" or (status == "error" and
not vm_exists_in_backend(vm)):
_process_net_status(vm, etime, nics=[])
already_deleted = vm.deleted
vm.deleted = True
vm.operstate = state_for_success
vm.backendtime = etime
# Issue and accept commission to Quotaholder
quotas.issue_and_accept_commission(vm, delete=True)
if not already_deleted:
quotas.issue_and_accept_commission(vm, delete=True)
# Update backendtime only for jobs that have been successfully completed,
# since only these jobs update the state of the VM. Else a "race condition"
......
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