From 9a0f1d89159f916fe71a13abe63840661cbd1c14 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Tue, 11 Sep 2018 06:28:53 +0200 Subject: [PATCH] VMware: Fix wait_for_task backoff behavior Signed-off-by: Harald Albers (cherry picked from commit 796d8b5dc8d36a84afe61b9da30779ef88e2cfcd) --- changelogs/fragments/vmware_wait_for_task_fix.yaml | 3 +++ lib/ansible/module_utils/vmware.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/vmware_wait_for_task_fix.yaml diff --git a/changelogs/fragments/vmware_wait_for_task_fix.yaml b/changelogs/fragments/vmware_wait_for_task_fix.yaml new file mode 100644 index 00000000000..e6860c1b199 --- /dev/null +++ b/changelogs/fragments/vmware_wait_for_task_fix.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: +- Fix timer in exponential backoff algorithm in vmware.py. diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 6a8be7eabba..8b32500e2aa 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -58,7 +58,7 @@ def wait_for_task(task, max_backoff=64, timeout=3600): finally: raise_from(TaskError(error_msg), task.info.error) if task.info.state in [vim.TaskInfo.State.running, vim.TaskInfo.State.queued]: - sleep_time = min(2 ** failure_counter + randint(1, 1000), max_backoff) + sleep_time = min(2 ** failure_counter + randint(1, 1000) / 1000, max_backoff) time.sleep(sleep_time) failure_counter += 1