From d31710337101358cbb56c3a312b42a7ce63a7c51 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 19 Sep 2013 14:11:36 -0500 Subject: [PATCH] Added in an accelerate connection timeout setting --- lib/ansible/constants.py | 1 + lib/ansible/runner/connection_plugins/accelerate.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 7391424682e..fdab0bf1684 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -136,6 +136,7 @@ PARAMIKO_RECORD_HOST_KEYS = get_config(p, 'paramiko_connection', 'record_ho ZEROMQ_PORT = get_config(p, 'fireball_connection', 'zeromq_port', 'ANSIBLE_ZEROMQ_PORT', 5099, integer=True) ACCELERATE_PORT = get_config(p, 'accelerate', 'accelerate_port', 'ACCELERATE_PORT', 5099, integer=True) ACCELERATE_TIMEOUT = int(get_config(p, 'accelerate', 'accelerate_timeout', 'ACCELERATE_TIMEOUT', 300)) +ACCELERATE_CONNECT_TIMEOUT = float(get_config(p, 'accelerate', 'accelerate_connect_timeout', 'ACCELERATE_CONNECT_TIMEOUT', 1.0)) DEFAULT_UNDEFINED_VAR_BEHAVIOR = get_config(p, DEFAULTS, 'error_on_undefined_vars', 'ANSIBLE_ERROR_ON_UNDEFINED_VARS', True, boolean=True) HOST_KEY_CHECKING = get_config(p, DEFAULTS, 'host_key_checking', 'ANSIBLE_HOST_KEY_CHECKING', True, boolean=True) diff --git a/lib/ansible/runner/connection_plugins/accelerate.py b/lib/ansible/runner/connection_plugins/accelerate.py index 0571fb25c76..414c070c7d2 100644 --- a/lib/ansible/runner/connection_plugins/accelerate.py +++ b/lib/ansible/runner/connection_plugins/accelerate.py @@ -103,7 +103,7 @@ class Connection(object): # TODO: make the timeout and retries configurable? tries = 3 self.conn = socket.socket() - self.conn.settimeout(self.runner.accelerate_timeout) + self.conn.settimeout(constants.ACCELERATE_CONNECT_TIMEOUT) vvvv("attempting connection to %s via the accelerated port %d" % (self.host,self.accport)) while tries > 0: try: @@ -116,6 +116,7 @@ class Connection(object): if tries == 0: vvv("Could not connect via the accelerated connection, exceeded # of tries") raise errors.AnsibleError("Failed to connect") + self.conn.settimeout(self.runner.accelerate_timeout) except: if allow_ssh: vvv("Falling back to ssh to startup accelerated mode")