diff options
| author | Mark Washenberger <mark.washenberger@rackspace.com> | 2012-05-11 09:47:10 -0400 |
|---|---|---|
| committer | Mark Washenberger <mark.washenberger@rackspace.com> | 2012-05-31 11:06:57 -0400 |
| commit | 91d007426f109dfef2142e28741edd51dcf1fdbc (patch) | |
| tree | c273c4faabe6d333e61399e621936fe802053bd6 /nova/compute | |
| parent | 0f2142b14adc442840c79a48add0dab78acf7c93 (diff) | |
Eliminate a race condition on instance deletes.
- Add constraint and equality conditions to nova.db[.sqlalchemy].api
- Use host constraints to ensure the compute api doesn't simply delete
an instance from the database that a compute manager has already
started to run.
This race condition is associated with bug #998117
Change-Id: Id74192d3e66bea073327342f57ce0f26987efd2d
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 9f96b8e6b..a3bd93bac 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -980,9 +980,15 @@ class API(base.Base): try: if not instance['host']: # Just update database, nothing else we can do - result = self.db.instance_destroy(context, instance['id']) - QUOTAS.commit(context, reservations) - return result + constraint = self.db.constraint(host=self.db.equal_any(host)) + try: + result = self.db.instance_destroy( + context, instance['uuid'], constraint) + QUOTAS.commit(context, reservations) + return result + except exception.ConstraintNotMet: + # Refresh to get new host information + instance = self.get(context, instance['uuid']) self.update(context, instance, |
