From dced117ea919b74d9521ff422b4eb8a880474a0d Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 13 Mar 2013 14:45:49 -0400 Subject: Generalize console error handling during build. There is a race condition where you can create an instance and then quickly request a VNC or Spice console before the instance is ready. The way this went down was different depending on the virt driver in use. The libvirt driver would raise InstanceNotFound. The xenapi driver would raise InstanceNotReady. This patch moves the handling of this race that was in the xenapi driver up to the compute manager. Now, all of the virt drivers that support this method (libvirt, xenapi, vmware) will all raise InstanceNotFound in this case, and the compute manager will convert it into InstanceNotReady IFF the vm_state is BUILDING. Related to bug 1154327. Change-Id: I68f4a6db8aac26c6f731c985d97299ee38c34448 --- nova/virt/xenapi/vmops.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 56dd5bd3d..fd028ecef 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -33,7 +33,6 @@ from nova.compute import instance_types from nova.compute import power_state from nova.compute import task_states from nova.compute import vm_mode -from nova.compute import vm_states from nova import context as nova_context from nova import exception from nova.openstack.common import excutils @@ -1325,20 +1324,11 @@ class VMOps(object): def get_vnc_console(self, instance): """Return connection info for a vnc console.""" - # NOTE(johannes): This can fail if the VM object hasn't been created - # yet on the dom0. Since that step happens fairly late in the build - # process, there's a potential for a race condition here. Until the - # VM object is created, return back a 409 error instead of a 404 - # error. try: vm_ref = self._get_vm_opaque_ref(instance) except exception.NotFound: - if instance['vm_state'] != vm_states.BUILDING: - raise - - LOG.info(_('Fetching VM ref while BUILDING failed'), - instance=instance) - raise exception.InstanceNotReady(instance_id=instance['uuid']) + # The compute manager expects InstanceNotFound for this case. + raise exception.InstanceNotFound(instance_id=instance['uuid']) session_id = self._session.get_session_id() path = "/console?ref=%s&session_id=%s" % (str(vm_ref), session_id) -- cgit