Merge "Retry on vmware create_vm when it fails"

This commit is contained in:
Zuul 2021-08-24 13:40:43 +00:00 committed by Gerrit Code Review
commit f4ee82aa23
2 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,7 @@
# under the License.
import collections
import fixtures
import mock
from oslo_utils import units
@ -1041,7 +1042,8 @@ class VMwareVMUtilTestCase(test.NoDBTestCase):
vm_util.ExtraSpecs(),
os_type='invalid_os_type')
self.assertRaises(vexc.VMwareDriverException,
# Because of retries timeout will be raised
self.assertRaises(fixtures.TimeoutException,
vm_util.create_vm, session, self._instance,
'folder', config_spec, 'res-pool')
self.assertTrue(found[0])

View File

@ -23,6 +23,7 @@ import copy
import functools
from oslo_log import log as logging
from oslo_service import loopingcall
from oslo_utils import excutils
from oslo_utils import units
from oslo_vmware import exceptions as vexc
@ -1325,6 +1326,9 @@ def get_vmdk_adapter_type(adapter_type):
return vmdk_adapter_type
@loopingcall.RetryDecorator(
max_retry_count=20, inc_sleep_time=2, max_sleep_time=20,
exceptions=(vexc.VimFaultException,))
def create_vm(session, instance, vm_folder, config_spec, res_pool_ref):
"""Create VM on ESX host."""
LOG.debug("Creating VM on the ESX host", instance=instance)