VMware: prevent race condition with VNC port allocation
When spawning some instances, nova VMware driver could have a race condition
in VNC port allocation. This fix ensures that the lock is done on the
actual setting in the VM configuration spec.
Co-authored-by: Marcio Roberto Starke <marcio.starke@serpro.gov.br>
Change-Id: I70fab021bbf2df418df53e5f47e19cf16dbe45ac
Closes-bug: #1357372
(cherry picked from commit 948ff4f3d0
)
This commit is contained in:
parent
da69a57f47
commit
ddd62ffdb1
|
@ -28,7 +28,6 @@ from nova import exception
|
|||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import units
|
||||
from nova import utils
|
||||
from nova.virt.vmwareapi import error_util
|
||||
from nova.virt.vmwareapi import vim_util
|
||||
|
||||
|
@ -674,7 +673,6 @@ def get_vnc_config_spec(client_factory, port):
|
|||
return virtual_machine_config_spec
|
||||
|
||||
|
||||
@utils.synchronized('vmware.get_vnc_port')
|
||||
def get_vnc_port(session):
|
||||
"""Return VNC port for an VM or None if there is no available port."""
|
||||
min_port = CONF.vmware.vnc_port
|
||||
|
|
|
@ -325,8 +325,7 @@ class VMwareVMOps(object):
|
|||
|
||||
# Set the vnc configuration of the instance, vnc port starts from 5900
|
||||
if CONF.vnc_enabled:
|
||||
vnc_port = vm_util.get_vnc_port(self._session)
|
||||
self._set_vnc_config(client_factory, instance, vnc_port)
|
||||
self._get_and_set_vnc_config(client_factory, instance)
|
||||
|
||||
def _create_virtual_disk(virtual_disk_path, file_size_in_kb):
|
||||
"""Create a virtual disk of the size of flat vmdk file."""
|
||||
|
@ -1580,8 +1579,10 @@ class VMwareVMOps(object):
|
|||
LOG.debug(_("Reconfigured VM instance to set the machine id"),
|
||||
instance=instance)
|
||||
|
||||
def _set_vnc_config(self, client_factory, instance, port):
|
||||
@utils.synchronized('vmware.get_and_set_vnc_port')
|
||||
def _get_and_set_vnc_config(self, client_factory, instance):
|
||||
"""Set the vnc configuration of the VM."""
|
||||
port = vm_util.get_vnc_port(self._session)
|
||||
vm_ref = vm_util.get_vm_ref(self._session, instance)
|
||||
|
||||
vnc_config_spec = vm_util.get_vnc_config_spec(
|
||||
|
|
Loading…
Reference in New Issue