diff options
| author | Édouard Thuleau <edouard.thuleau@orange.com> | 2012-11-08 16:14:37 +0100 |
|---|---|---|
| committer | Édouard Thuleau <edouard.thuleau@orange.com> | 2012-11-21 22:44:57 +0100 |
| commit | d32d5b252fc6c71a19b5372defb468fee9c57d3a (patch) | |
| tree | a27f41bd3e3e11a0faa18a32a16e9dc755465062 /nova/compute | |
| parent | 5582d203b77741a005687a87673d9fce11b5ee09 (diff) | |
Compute doesn't set the 'host' field in instance
When an instance starts, compute ask the resource manager to check the
compute capabilities. If the compute resources are sufficient, the
resource manager updates the 'host' instance field in the database. But
the local variable 'instance' use by compute manger isn't updated.
So, when compute manager asks the network manager to allocate a network
for the instance, the 'host' instance field is null.
Some compute tests doesn't update the local variable instance when
they change some parameter on instance and failed with this patch.
Fixes LP bug #1073600
Change-Id: I842d4814b9eabc6222c68118d8a244b20bb68164
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 5 | ||||
| -rw-r--r-- | nova/compute/resource_tracker.py | 21 |
2 files changed, 15 insertions, 11 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index eab4906b0..5d5a4b582 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1762,6 +1762,11 @@ class ComputeManager(manager.SchedulerDependentManager): if not filter_properties: filter_properties = {} + if not instance['host']: + self._set_instance_error_state(context, instance['uuid']) + msg = _('Instance has no source host') + raise exception.MigrationError(msg) + same_host = instance['host'] == self.host if same_host and not CONF.allow_resize_to_same_host: self._set_instance_error_state(context, instance['uuid']) diff --git a/nova/compute/resource_tracker.py b/nova/compute/resource_tracker.py index 17d0869ad..7bb402916 100644 --- a/nova/compute/resource_tracker.py +++ b/nova/compute/resource_tracker.py @@ -83,22 +83,20 @@ class ResourceTracker(object): if self.disabled: # compute_driver doesn't support resource tracking, just # set the 'host' field and continue the build: - instance_ref = self._set_instance_host(context, - instance_ref['uuid']) + self._set_instance_host(context, instance_ref) return claims.NopClaim() # sanity check: if instance_ref['host']: - LOG.warning(_("Host field should be not be set on the instance " - "until resources have been claimed."), + LOG.warning(_("Host field should not be set on the instance until " + "resources have been claimed."), instance=instance_ref) claim = claims.Claim(instance_ref, self) if claim.test(self.compute_node, limits): - instance_ref = self._set_instance_host(context, - instance_ref['uuid']) + self._set_instance_host(context, instance_ref) # Mark resources in-use and update stats self._update_usage_from_instance(self.compute_node, instance_ref) @@ -170,16 +168,17 @@ class ResourceTracker(object): 'new_instance_type_id': instance_type['id'], 'status': 'pre-migrating'}) - def _set_instance_host(self, context, instance_uuid): + def _set_instance_host(self, context, instance_ref): """Tag the instance as belonging to this host. This should be done while the COMPUTE_RESOURCES_SEMPAHORE is held so the resource claim will not be lost if the audit process starts. """ values = {'host': self.host, 'launched_on': self.host} - (old_ref, instance_ref) = db.instance_update_and_get_original(context, - instance_uuid, values) - notifications.send_update(context, old_ref, instance_ref) - return instance_ref + (old_ref, new_ref) = db.instance_update_and_get_original(context, + instance_ref['uuid'], values) + notifications.send_update(context, old_ref, new_ref) + instance_ref['host'] = self.host + instance_ref['launched_on'] = self.host def abort_instance_claim(self, instance): """Remove usage from the given instance""" |
