Merge lp:~gz/workspace-runner/ssh_server_alive into lp:workspace-runner

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: 27
Merged at revision: 27
Proposed branch: lp:~gz/workspace-runner/ssh_server_alive
Merge into: lp:workspace-runner
Prerequisite: lp:~gz/workspace-runner/sorted_walk_results
Diff against target: 78 lines (+8/-5)
2 files modified
workspace_runner/__init__.py (+1/-1)
workspace_runner/tests/__init__.py (+7/-4)
To merge this branch: bzr merge lp:~gz/workspace-runner/ssh_server_alive
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+299722@code.launchpad.net

Commit message

Add ServerAliveInterval=120 option when using ssh

Description of the change

It seems the timeouts on the race job under workspace runner are due to a long period with no output from the remote end and no activity from the runner.

The last line in the gating race output is the api/watcher suite. Next up would be apiserver, which takes >400 seconds to complete in the main race job.

ok github.com/juju/juju/api/watcher 14.754s
ok github.com/juju/juju/apiserver 403.091s

We can try to work around this by getting the client to poke at a regular interval. For now, seeing if 2 minutes is good enough.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

Works for me.

I was a little surprised to see ssh_options becoming a class variable instead of an instance variable, but I guess it doesn't matter much-- class variables can always be overridden.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'workspace_runner/__init__.py'
2--- workspace_runner/__init__.py 2015-10-08 23:44:14 +0000
3+++ workspace_runner/__init__.py 2016-07-11 18:17:23 +0000
4@@ -78,12 +78,12 @@
5
6 It includes the host and private key (if any) to use.
7 """
8+ ssh_options = ('StrictHostKeyChecking=no', 'ServerAliveInterval=120')
9
10 def __init__(self, host, private_key):
11 self.host = host
12 self.private_key = private_key
13 self.known_hosts = None
14- self.ssh_options = ['StrictHostKeyChecking=no']
15
16 def get_ssh_options(self):
17 """Return the standard options for this SSH connection."""
18
19=== modified file 'workspace_runner/tests/__init__.py'
20--- workspace_runner/tests/__init__.py 2016-07-11 18:17:23 +0000
21+++ workspace_runner/tests/__init__.py 2016-07-11 18:17:23 +0000
22@@ -217,6 +217,7 @@
23 self.assertEqual(
24 connection.get_ssh_options(), [
25 '-oStrictHostKeyChecking=no',
26+ '-oServerAliveInterval=120',
27 '-oUserKnownHostsFile=/dev/null',
28 '-i', 'private-key'])
29
30@@ -226,6 +227,7 @@
31 self.assertEqual(
32 connection.get_ssh_options(), [
33 '-oStrictHostKeyChecking=no',
34+ '-oServerAliveInterval=120',
35 '-oUserKnownHostsFile=foo/bar/baz'])
36
37 def test_call_with_input_error(self):
38@@ -241,6 +243,7 @@
39 connection.scp_dir_from_remote('source', 'dest')
40 pc_mock.assert_called_once_with(
41 ['scp', '-r', '-oStrictHostKeyChecking=no',
42+ '-oServerAliveInterval=120',
43 '-oUserKnownHostsFile=/dev/null', '-i', 'key',
44 'host@example.com:source/', 'dest'])
45
46@@ -299,13 +302,13 @@
47
48 def expect_run(self, primitives, args, out_file):
49 def effect(args, stdout):
50- stdout.write(''.join(args[7:]))
51+ stdout.write(''.join(args[8:]))
52
53 with patch('subprocess.check_call', side_effect=effect,
54 autospec=True) as cc_mock:
55 primitives.run(args, out_file)
56 call_args = [
57- 'ssh', '-oStrictHostKeyChecking=no',
58+ 'ssh', '-oStrictHostKeyChecking=no', '-oServerAliveInterval=120',
59 '-oUserKnownHostsFile=/dev/null',
60 primitives.ssh_connection.host, 'cd', quote(primitives.workspace),
61 ';'] + args,
62@@ -321,7 +324,7 @@
63 dest = '{}:{}/'.format(primitives.ssh_connection.host,
64 os.path.join(primitives.workspace, dest))
65 po_mock.assert_called_once_with(
66- ['ssh', '-oStrictHostKeyChecking=no',
67+ ['ssh', '-oStrictHostKeyChecking=no', '-oServerAliveInterval=120',
68 '-oUserKnownHostsFile=/dev/null',
69 'asdf', 'python - /tmp/workspace/install-dir'],
70 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
71@@ -333,7 +336,7 @@
72 os.mkdir(sys.argv[1])
73 """))
74 cc_mock.assert_called_once_with([
75- 'scp', '-oStrictHostKeyChecking=no',
76+ 'scp', '-oStrictHostKeyChecking=no', '-oServerAliveInterval=120',
77 '-oUserKnownHostsFile=/dev/null',
78 ] + sources + [dest])
79

Subscribers

People subscribed via source and target branches