VMware:Config option to disable lazy volume create

Currently the backend volume is created lazily for raw
volume create operations. The backend volume is created
during the initial attach. This is to minimize unnecessary
volume migrations across datastores in the backend which
may be required if the backend volume is not accessible to
instance VM's ESX host. In certain vCenter configurations,
it may be required to disable this lazy creation. This would
reduce the time spent in the backend during volume attach.
Introducing a config option to disable lazy volume create
if necessary.

Change-Id: I3feb6b382ff75eb53d53f145ae3773b6320e703c
Closes-bug: #1739390
This commit is contained in:
Vipin Balachandran 2018-01-03 14:57:32 -08:00
parent 52d2ef021f
commit 18c8af402b
3 changed files with 27 additions and 2 deletions

View File

@ -97,6 +97,7 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
self._config.vmware_connection_pool_size = self.POOL_SIZE self._config.vmware_connection_pool_size = self.POOL_SIZE
self._config.vmware_adapter_type = self.ADAPTER_TYPE self._config.vmware_adapter_type = self.ADAPTER_TYPE
self._config.vmware_snapshot_format = self.SNAPSHOT_FORMAT self._config.vmware_snapshot_format = self.SNAPSHOT_FORMAT
self._config.vmware_lazy_create = True
self._db = mock.Mock() self._db = mock.Mock()
self._driver = vmdk.VMwareVcVmdkDriver(configuration=self._config, self._driver = vmdk.VMwareVcVmdkDriver(configuration=self._config,
@ -169,6 +170,14 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
verify_volume_creation.assert_called_once_with(volume) verify_volume_creation.assert_called_once_with(volume)
@mock.patch.object(VMDK_DRIVER, '_create_backing')
def test_create_volume_with_lazy_create_disabled(self, create_backing):
self._config.vmware_lazy_create = False
volume = self._create_volume_dict()
self._driver.create_volume(volume)
create_backing.assert_called_once_with(volume)
@mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'volumeops')
def test_delete_volume_without_backing(self, vops): def test_delete_volume_without_backing(self, vops):
vops.get_backing.return_value = None vops.get_backing.return_value = None

View File

@ -144,6 +144,12 @@ vmdk_opts = [
choices=['template', 'COW'], choices=['template', 'COW'],
default='template', default='template',
help='Volume snapshot format in vCenter server.'), help='Volume snapshot format in vCenter server.'),
cfg.BoolOpt('vmware_lazy_create',
default=True,
help='If true, the backend volume in vCenter server is created'
' lazily when the volume is created without any source. '
'The backend volume is created when the volume is '
'attached, uploaded to image service or during backup.'),
] ]
CONF = cfg.CONF CONF = cfg.CONF
@ -251,7 +257,8 @@ class VMwareVcVmdkDriver(driver.VolumeDriver):
# support for revert-to-snapshot # support for revert-to-snapshot
# improve scalability of querying volumes in backend (bug 1600754) # improve scalability of querying volumes in backend (bug 1600754)
# 3.1.0 - support adapter type change using retype # 3.1.0 - support adapter type change using retype
VERSION = '3.1.0' # 3.2.0 - config option to disable lazy creation of backend volume
VERSION = '3.2.0'
# ThirdPartySystems wiki page # ThirdPartySystems wiki page
CI_WIKI_NAME = "VMware_CI" CI_WIKI_NAME = "VMware_CI"
@ -355,7 +362,10 @@ class VMwareVcVmdkDriver(driver.VolumeDriver):
:param volume: Volume object :param volume: Volume object
""" """
self._verify_volume_creation(volume) if self.configuration.vmware_lazy_create:
self._verify_volume_creation(volume)
else:
self._create_backing(volume)
def _delete_volume(self, volume): def _delete_volume(self, volume):
"""Delete the volume backing if it is present. """Delete the volume backing if it is present.

View File

@ -0,0 +1,6 @@
---
features:
- |
VMware VMDK driver now supports a config option
``vmware_lazy_create`` to disable the default behavior of
lazy creation of raw volumes in the backend.