summaryrefslogtreecommitdiff
path: root/lib/ansible/executor/powershell
diff options
context:
space:
mode:
authorXyon <admin@jbladen.co.uk>2020-01-23 20:04:52 +0000
committerJordan Borean <jborean93@gmail.com>2020-01-24 06:04:52 +1000
commit5c721e8a47848543b4e111783235eafff221666c (patch)
treee39eff0d4f1d013469efe84ab164b66ba9304860 /lib/ansible/executor/powershell
parent14cc63dc0f765eaf20364063fd59526d3d592c5c (diff)
downloadansible-5c721e8a47848543b4e111783235eafff221666c.tar.gz
Add new configuration parameter to make Windows async startup timeout configurable (#66670)
* Add new configuration parameter to make this timeout configurable * Rename keys to be more correct and reformat exception message for whitespace handling * Rename config away from default prefix. Add vars element and associated changes to support. * Update 65001-allow_configuring_async_startup_timeout.yml Co-authored-by: Matt Davis <nitzmahone@users.noreply.github.com>
Diffstat (limited to 'lib/ansible/executor/powershell')
-rw-r--r--lib/ansible/executor/powershell/async_wrapper.ps111
-rw-r--r--lib/ansible/executor/powershell/module_manifest.py1
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/ansible/executor/powershell/async_wrapper.ps1 b/lib/ansible/executor/powershell/async_wrapper.ps1
index 545b4a5623..93ad52ecbd 100644
--- a/lib/ansible/executor/powershell/async_wrapper.ps1
+++ b/lib/ansible/executor/powershell/async_wrapper.ps1
@@ -145,11 +145,16 @@ try {
$result_json = ConvertTo-Json -InputObject $result -Depth 99 -Compress
Set-Content $results_path -Value $result_json
- Write-AnsibleLog "INFO - waiting for async process to connect to named pipe for 5 seconds" "async_wrapper"
+ $np_timeout = $Payload.async_startup_timeout * 1000
+ Write-AnsibleLog "INFO - waiting for async process to connect to named pipe for $np_timeout milliseconds" "async_wrapper"
$wait_async = $pipe.BeginWaitForConnection($null, $null)
- $wait_async.AsyncWaitHandle.WaitOne(5000) > $null
+ $wait_async.AsyncWaitHandle.WaitOne($np_timeout) > $null
if (-not $wait_async.IsCompleted) {
- throw "timeout while waiting for child process to connect to named pipe"
+ $msg = "Ansible encountered a timeout while waiting for the async task to start and connect to the named"
+ $msg += "pipe. This can be affected by the performance of the target - you can increase this timeout using"
+ $msg += "WIN_ASYNC_STARTUP_TIMEOUT or just for this host using the win_async_startup_timeout hostvar if "
+ $msg += "this keeps happening."
+ throw $msg
}
$pipe.EndWaitForConnection($wait_async)
diff --git a/lib/ansible/executor/powershell/module_manifest.py b/lib/ansible/executor/powershell/module_manifest.py
index 4cea859631..aa746d4755 100644
--- a/lib/ansible/executor/powershell/module_manifest.py
+++ b/lib/ansible/executor/powershell/module_manifest.py
@@ -294,6 +294,7 @@ def _create_powershell_wrapper(b_module_data, module_path, module_args,
exec_manifest["actions"].insert(0, 'async_wrapper')
exec_manifest["async_jid"] = str(random.randint(0, 999999999999))
exec_manifest["async_timeout_sec"] = async_timeout
+ exec_manifest["async_startup_timeout"] = C.config.get_config_value("WIN_ASYNC_STARTUP_TIMEOUT", variables=task_vars)
if become and become_method == 'runas':
finder.scan_exec_script('exec_wrapper')