Merge lp:~sinzui/juju-ci-tools/wait-for-upgrade into lp:juju-ci-tools

Proposed by Curtis Hovey
Status: Merged
Merged at revision: 1783
Proposed branch: lp:~sinzui/juju-ci-tools/wait-for-upgrade
Merge into: lp:juju-ci-tools
Diff against target: 61 lines (+27/-5)
2 files modified
deploy_stack.py (+17/-0)
tests/test_deploy_stack.py (+10/-5)
To merge this branch: bzr merge lp:~sinzui/juju-ci-tools/wait-for-upgrade
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Review via email: mp+312274@code.launchpad.net

Description of the change

Wait for list-models to work to know when the controller has upgraded.

Older jujus went dark for many minutes during an upgrade. We polled status for a time and when it worked, we started checking for the upgraded agent version. New juju does not go completely dark. status will works, and it will report the agents are upgraded, but the controller is *still* upgrading.

This branch treats list-models like status. After we see the agent are upgraded, we try list-models for a period of time. When the command works the script proceeds. Otherwise a timeout is raised.

Neither status nor show controller indicates that mongos collections are being upgraded. Our only clue is that we cannot work with any model.

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This looks good, but I'd prefer we put a small comment in as to why we are doing the additional wait. A summary of what you've said above for future reference in the test. Namely, upgrades occur on agent and potentially db as well. Juju doesn't tell us when it's truly done. We are using list-models as the proxy for 'juju done'.

review: Approve
1784. By Curtis Hovey

Added comments.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deploy_stack.py'
2--- deploy_stack.py 2016-11-28 22:17:20 +0000
3+++ deploy_stack.py 2016-12-01 16:40:43 +0000
4@@ -401,8 +401,25 @@
5 timeout = 600
6
7 for client in all_clients:
8+ logging.info('Upgrading {}'.format(client.env.environment))
9 upgrade_juju(client)
10 client.wait_for_version(client.get_matching_agent_version(), timeout)
11+ logging.info('Agents upgraded in {}'.format(client.env.environment))
12+ client.show_status()
13+ logging.info('Waiting for model {}'.format(client.env.environment))
14+ # While the agents are upgraded, the controller/model may still be
15+ # upgrading. We are only certain that the upgrade as is complete
16+ # when we can list models.
17+ for ignore in until_timeout(600):
18+ try:
19+ client.list_models()
20+ break
21+ except subprocess.CalledProcessError:
22+ pass
23+ # The upgrade will trigger the charm hooks. We want the charms to
24+ # return to active state to know they accepted the upgrade.
25+ client.wait_for_workloads()
26+ logging.info('Upgraded model {}'.format(client.env.environment))
27
28
29 def _get_clients_to_upgrade(old_client, juju_path):
30
31=== modified file 'tests/test_deploy_stack.py'
32--- tests/test_deploy_stack.py 2016-11-28 22:04:46 +0000
33+++ tests/test_deploy_stack.py 2016-12-01 16:40:43 +0000
34@@ -1207,17 +1207,22 @@
35 'juju', '--show-log', 'upgrade-juju', '-m', 'foo:controller',
36 '--agent-version', '2.0-rc2'), 0)
37 assert_juju_call(self, cc_mock, new_client, (
38+ 'juju', '--show-log', 'show-status', '-m', 'foo:controller',
39+ '--format', 'yaml'), 1)
40+ assert_juju_call(self, cc_mock, new_client, (
41+ 'juju', '--show-log', 'list-models', '-c', 'foo'), 2)
42+ assert_juju_call(self, cc_mock, new_client, (
43 'juju', '--show-log', 'upgrade-juju', '-m', 'foo:foo',
44- '--agent-version', '2.0-rc2'), 1)
45- self.assertEqual(cc_mock.call_count, 2)
46+ '--agent-version', '2.0-rc2'), 3)
47+ self.assertEqual(cc_mock.call_count, 6)
48 assert_juju_call(self, co_mock, new_client, self.LIST_MODELS, 0)
49 assert_juju_call(self, co_mock, new_client, self.GET_CONTROLLER_ENV, 1)
50 assert_juju_call(self, co_mock, new_client, self.GET_CONTROLLER_ENV, 2)
51 assert_juju_call(self, co_mock, new_client, self.CONTROLLER_STATUS, 3)
52- assert_juju_call(self, co_mock, new_client, self.GET_ENV, 4)
53 assert_juju_call(self, co_mock, new_client, self.GET_ENV, 5)
54- assert_juju_call(self, co_mock, new_client, self.STATUS, 6)
55- self.assertEqual(co_mock.call_count, 7)
56+ assert_juju_call(self, co_mock, new_client, self.GET_ENV, 6)
57+ assert_juju_call(self, co_mock, new_client, self.STATUS, 7)
58+ self.assertEqual(co_mock.call_count, 9)
59
60 def test__get_clients_to_upgrade_returns_new_version_class(self):
61 env = SimpleEnvironment('foo', {'type': 'foo'})

Subscribers

People subscribed via source and target branches