summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRicardo Carrillo Cruz <ricardo.carrillo.cruz@gmail.com>2018-01-13 15:54:44 +0100
committerGitHub <noreply@github.com>2018-01-13 15:54:44 +0100
commita56de25df55b5ec5d41cc97e7a9b8c466718366b (patch)
treebdfd97630bb66a6fac820f171b87ce65b7693333 /lib
parentc548ab0f18cf1b97456081b108f1c5af49a64532 (diff)
downloadansible-a56de25df55b5ec5d41cc97e7a9b8c466718366b.tar.gz
Fix persistent command timeout handling (#34791)
* Fix persistent command timeout handling We were using play context timeout on ansible-connect to set the persistent command timeout handler. Thus, we were ignoring the persistent_command_timeout setting. Moreover, even by changing that on ansible-connection, were again overriding it on cliconf send_command, since in a same process we can just set a single alarm and cliconf send_command alarm setup is executed after ansible-connection alarm setup. * Remove alarm setting on cliconf send_command The alarm is set regardless before it is executed by ansible-connection. Setting an alarm again, overrides/disables the previous ones as a single process can just have a single alarm set. * Move the setting of persistent command timeout to network_cli We do also use ansible-connection for connection local, so if a user provides a timeout via provider that would be ignored if we set the value on ansible-connection. Moving that logic to network_cli plugin constructor makes both connections to work. * Remove debug statements * Set the persistent command timeout on task_executor We can't set the timeout on ansible-connection nor network_cli, otherwise tasks using provider timeout won't work.
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/executor/task_executor.py1
-rw-r--r--lib/ansible/plugins/cliconf/__init__.py4
2 files changed, 1 insertions, 4 deletions
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index 086db41935..9adc7e1352 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -743,6 +743,7 @@ class TaskExecutor:
self._play_context.set_options_from_plugin(connection)
if any(((connection.supports_persistence and C.USE_PERSISTENT_CONNECTIONS), connection.force_persistence)):
+ self._play_context.timeout = C.PERSISTENT_COMMAND_TIMEOUT
display.vvvv('attempting to start connection', host=self._play_context.remote_addr)
display.vvvv('using connection plugin %s' % connection.transport, host=self._play_context.remote_addr)
socket_path = self._start_connection()
diff --git a/lib/ansible/plugins/cliconf/__init__.py b/lib/ansible/plugins/cliconf/__init__.py
index 44696ef0d4..0aaca9e47f 100644
--- a/lib/ansible/plugins/cliconf/__init__.py
+++ b/lib/ansible/plugins/cliconf/__init__.py
@@ -106,11 +106,7 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
if answer is not None:
kwargs['answer'] = to_bytes(answer)
- if not signal.getsignal(signal.SIGALRM):
- signal.signal(signal.SIGALRM, self._alarm_handler)
- signal.alarm(self._connection._play_context.timeout)
resp = self._connection.send(**kwargs)
- signal.alarm(0)
return resp
def get_base_rpc(self):