Skip to content

Commit 3620fce

Browse files
committed
issue #593: expose configurables for SSH keepalive and increase the default
1 parent 823c18e commit 3620fce

File tree

6 files changed

+61
-2
lines changed

6 files changed

+61
-2
lines changed

ansible_mitogen/connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ def _connect_ssh(spec):
145145
'ssh_args': spec.ssh_args(),
146146
'ssh_debug_level': spec.mitogen_ssh_debug_level(),
147147
'remote_name': get_remote_name(spec),
148+
'keepalive_count': (
149+
spec.mitogen_ssh_keepalive_count() or 10
150+
),
151+
'keepalive_interval': (
152+
spec.mitogen_ssh_keepalive_interval() or 30
153+
),
148154
}
149155
}
150156

ansible_mitogen/transport_config.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,18 @@ def mitogen_machinectl_path(self):
276276
The path to the "machinectl" program for the 'setns' transport.
277277
"""
278278

279+
@abc.abstractmethod
280+
def mitogen_ssh_keepalive_interval(self):
281+
"""
282+
The SSH ServerAliveInterval.
283+
"""
284+
285+
@abc.abstractmethod
286+
def mitogen_ssh_keepalive_count(self):
287+
"""
288+
The SSH ServerAliveCount.
289+
"""
290+
279291
@abc.abstractmethod
280292
def mitogen_ssh_debug_level(self):
281293
"""
@@ -427,6 +439,12 @@ def mitogen_lxc_attach_path(self):
427439
def mitogen_lxc_info_path(self):
428440
return self._connection.get_task_var('mitogen_lxc_info_path')
429441

442+
def mitogen_ssh_keepalive_interval(self):
443+
return self._connection.get_task_var('mitogen_ssh_keepalive_interval')
444+
445+
def mitogen_ssh_keepalive_count(self):
446+
return self._connection.get_task_var('mitogen_ssh_keepalive_count')
447+
430448
def mitogen_machinectl_path(self):
431449
return self._connection.get_task_var('mitogen_machinectl_path')
432450

@@ -644,6 +662,12 @@ def mitogen_lxc_attach_path(self):
644662
def mitogen_lxc_info_path(self):
645663
return self._host_vars.get('mitogen_lxc_info_path')
646664

665+
def mitogen_ssh_keepalive_interval(self):
666+
return self._host_vars.get('mitogen_ssh_keepalive_interval')
667+
668+
def mitogen_ssh_keepalive_count(self):
669+
return self._host_vars.get('mitogen_ssh_keepalive_count')
670+
647671
def mitogen_machinectl_path(self):
648672
return self._host_vars.get('mitogen_machinectl_path')
649673

docs/ansible_detailed.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,11 @@ except connection delegation is supported.
10071007
otherwise :data:`False`. This will change to off by default in a future
10081008
release. If you are targetting many hosts on a fast network, please consider
10091009
disabling SSH compression.
1010+
* ``mitogen_ssh_keepalive_count``: integer count of server keepalive messages to
1011+
which no reply is received before considering the SSH server dead. Defaults
1012+
to 10.
1013+
* ``mitogen_ssh_keepalive_count``: integer seconds delay between keepalive
1014+
messages. Defaults to 30.
10101015

10111016

10121017
Debugging

docs/changelog.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ Fixes
4545
:func:`os.getcwd` prior to :class:`AnsibleModule` initialization, such as the
4646
Ansible 2.7 ``pip`` module, cannot fail due to the behavior of a prior task.
4747

48+
* `#593 <https://github.com/dw/mitogen/issues/593>`_: the SSH connection method
49+
exposes ``mitogen_ssh_keepalive_interval`` and
50+
``mitogen_ssh_keepalive_count`` variables, and the default timeout for an SSH
51+
server has been increased from `15*3` seconds to `30*10` seconds.
52+
4853

4954
Thanks!
5055
~~~~~~~
@@ -53,8 +58,9 @@ Mitogen would not be possible without the support of users. A huge thanks for
5358
bug reports, testing, features and fixes in this release contributed by
5459
`Anton Markelov <https://github.com/strangeman>`_,
5560
`Nigel Metheringham <https://github.com/nigelm>`_,
56-
`Orion Poplawski <https://github.com/opoplawski>`_, and
57-
`Ulrich Schreiner <https://github.com/ulrichSchreiner>`_.
61+
`Orion Poplawski <https://github.com/opoplawski>`_,
62+
`Ulrich Schreiner <https://github.com/ulrichSchreiner>`_, and
63+
`Yuki Nishida <https://github.com/yuki-nishida-exa>`_.
5864

5965

6066
v0.2.7 (2019-05-19)

tests/ansible/integration/connection_delegation/delegate_to_template.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
'hostname': 'alias-host',
3838
'identities_only': False,
3939
'identity_file': null,
40+
'keepalive_interval': 30,
41+
'keepalive_count': 10,
4042
'password': null,
4143
'port': null,
4244
'python_path': ["/usr/bin/python"],
@@ -65,6 +67,8 @@
6567
'hostname': 'cd-normal-alias',
6668
'identities_only': False,
6769
'identity_file': null,
70+
'keepalive_interval': 30,
71+
'keepalive_count': 10,
6872
'password': null,
6973
'port': null,
7074
'python_path': ["/usr/bin/python"],

tests/ansible/integration/connection_delegation/stack_construction.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
'hostname': 'alias-host',
7272
'identities_only': False,
7373
'identity_file': null,
74+
'keepalive_interval': 30,
75+
'keepalive_count': 10,
7476
'password': null,
7577
'port': null,
7678
"python_path": ["/usr/bin/python"],
@@ -112,6 +114,8 @@
112114
'hostname': 'alias-host',
113115
'identities_only': False,
114116
'identity_file': null,
117+
'keepalive_interval': 30,
118+
'keepalive_count': 10,
115119
'password': null,
116120
'port': null,
117121
"python_path": ["/usr/bin/python"],
@@ -164,6 +168,8 @@
164168
'hostname': 'cd-normal-normal',
165169
'identities_only': False,
166170
'identity_file': null,
171+
'keepalive_interval': 30,
172+
'keepalive_count': 10,
167173
'password': null,
168174
'port': null,
169175
"python_path": ["/usr/bin/python"],
@@ -205,6 +211,8 @@
205211
'hostname': 'alias-host',
206212
'identities_only': False,
207213
'identity_file': null,
214+
'keepalive_interval': 30,
215+
'keepalive_count': 10,
208216
'password': null,
209217
'port': null,
210218
"python_path": ["/usr/bin/python"],
@@ -233,6 +241,8 @@
233241
'hostname': 'cd-normal-alias',
234242
'identities_only': False,
235243
'identity_file': null,
244+
'keepalive_interval': 30,
245+
'keepalive_count': 10,
236246
'password': null,
237247
'port': null,
238248
"python_path": ["/usr/bin/python"],
@@ -285,6 +295,8 @@
285295
'hostname': 'cd-newuser-normal-normal',
286296
'identities_only': False,
287297
'identity_file': null,
298+
'keepalive_interval': 30,
299+
'keepalive_count': 10,
288300
'password': null,
289301
'port': null,
290302
"python_path": ["/usr/bin/python"],
@@ -327,6 +339,8 @@
327339
'hostname': 'alias-host',
328340
'identities_only': False,
329341
'identity_file': null,
342+
'keepalive_interval': 30,
343+
'keepalive_count': 10,
330344
'password': null,
331345
'port': null,
332346
"python_path": ["/usr/bin/python"],

0 commit comments

Comments
 (0)