Merge lp:~blake-rouse/maas/deploy-cloudinit-reboot into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 5597
Proposed branch: lp:~blake-rouse/maas/deploy-cloudinit-reboot
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 205 lines (+48/-28)
9 files modified
contrib/preseeds_v2/curtin_userdata (+0/-3)
contrib/preseeds_v2/curtin_userdata_centos (+0/-3)
contrib/preseeds_v2/curtin_userdata_custom (+0/-3)
contrib/preseeds_v2/curtin_userdata_suse (+0/-3)
contrib/preseeds_v2/curtin_userdata_windows (+0/-3)
src/maasserver/compose_preseed.py (+9/-2)
src/maasserver/preseed.py (+8/-1)
src/maasserver/tests/test_compose_preseed.py (+6/-0)
src/maasserver/tests/test_preseed.py (+25/-10)
To merge this branch: bzr merge lp:~blake-rouse/maas/deploy-cloudinit-reboot
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+312637@code.launchpad.net

Commit message

Use cloud-init to reboot deployment instead of curtin starting the power off.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (33.6 KiB)

The attempt to merge lp:~blake-rouse/maas/deploy-cloudinit-reboot into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:5 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe Sources [111 kB]
Get:6 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [440 kB]
Get:7 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [367 kB]
Get:8 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [134 kB]
Fetched 1,358 kB in 0s (1,593 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest ...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'contrib/preseeds_v2/curtin_userdata'
2--- contrib/preseeds_v2/curtin_userdata 2016-10-13 15:48:56 +0000
3+++ contrib/preseeds_v2/curtin_userdata 2016-12-08 07:42:09 +0000
4@@ -24,6 +24,3 @@
5 driver_06_depmod: ["curtin", "in-target", "--", "depmod"]
6 driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"]
7 {{endif}}
8-
9-power_state:
10- mode: reboot
11
12=== modified file 'contrib/preseeds_v2/curtin_userdata_centos'
13--- contrib/preseeds_v2/curtin_userdata_centos 2016-07-30 01:17:54 +0000
14+++ contrib/preseeds_v2/curtin_userdata_centos 2016-12-08 07:42:09 +0000
15@@ -7,6 +7,3 @@
16
17 late_commands:
18 maas: [wget, '--no-proxy', '{{node_disable_pxe_url}}', '--post-data', '{{node_disable_pxe_data}}', '-O', '/dev/null']
19-
20-power_state:
21- mode: reboot
22
23=== modified file 'contrib/preseeds_v2/curtin_userdata_custom'
24--- contrib/preseeds_v2/curtin_userdata_custom 2014-09-23 20:44:48 +0000
25+++ contrib/preseeds_v2/curtin_userdata_custom 2016-12-08 07:42:09 +0000
26@@ -7,6 +7,3 @@
27
28 late_commands:
29 maas: [wget, '--no-proxy', '{{node_disable_pxe_url}}', '--post-data', '{{node_disable_pxe_data}}', '-O', '/dev/null']
30-
31-power_state:
32- mode: reboot
33
34=== modified file 'contrib/preseeds_v2/curtin_userdata_suse'
35--- contrib/preseeds_v2/curtin_userdata_suse 2014-06-18 13:27:28 +0000
36+++ contrib/preseeds_v2/curtin_userdata_suse 2016-12-08 07:42:09 +0000
37@@ -7,6 +7,3 @@
38
39 late_commands:
40 maas: [wget, '--no-proxy', '{{node_disable_pxe_url}}', '--post-data', '{{node_disable_pxe_data}}', '-O', '/dev/null']
41-
42-power_state:
43- mode: reboot
44
45=== modified file 'contrib/preseeds_v2/curtin_userdata_windows'
46--- contrib/preseeds_v2/curtin_userdata_windows 2014-10-15 22:34:13 +0000
47+++ contrib/preseeds_v2/curtin_userdata_windows 2016-12-08 07:42:09 +0000
48@@ -9,6 +9,3 @@
49 maas: [wget, '--no-proxy', '{{node_disable_pxe_url}}', '--post-data', '{{node_disable_pxe_data}}', '-O', '/dev/null']
50
51 license_key: {{node.get_effective_license_key()}}
52-
53-power_state:
54- mode: reboot
55
56=== modified file 'src/maasserver/compose_preseed.py'
57--- src/maasserver/compose_preseed.py 2016-10-05 20:08:01 +0000
58+++ src/maasserver/compose_preseed.py 2016-12-08 07:42:09 +0000
59@@ -254,12 +254,13 @@
60 """Compose the preseed value for a node being installed with curtin."""
61 metadata_url = absolute_reverse('curtin-metadata', base_url=base_url)
62 return _compose_cloud_init_preseed(
63- node, token, metadata_url, base_url=base_url)
64+ node, token, metadata_url, base_url=base_url, reboot=True)
65
66
67 def _compose_cloud_init_preseed(
68 node, token, metadata_url, base_url, poweroff=False,
69- poweroff_timeout=3600, poweroff_condition=None):
70+ poweroff_timeout=3600, poweroff_condition=None,
71+ reboot=False, reboot_timeout=1800):
72 cloud_config = {
73 'datasource': {
74 'MAAS': {
75@@ -303,6 +304,12 @@
76 }
77 if poweroff_condition is not None:
78 cloud_config['power_state']['condition'] = poweroff_condition
79+ if reboot:
80+ cloud_config['power_state'] = {
81+ 'delay': 'now',
82+ 'mode': 'reboot',
83+ 'timeout': reboot_timeout,
84+ }
85 return "#cloud-config\n%s" % yaml.safe_dump(cloud_config)
86
87
88
89=== modified file 'src/maasserver/preseed.py'
90--- src/maasserver/preseed.py 2016-12-07 12:46:14 +0000
91+++ src/maasserver/preseed.py 2016-12-08 07:42:09 +0000
92@@ -417,7 +417,14 @@
93 get_node_preseed_context(
94 node, osystem, series, rack_controller=rack_controller))
95 context.update(get_curtin_context(node, rack_controller=rack_controller))
96- return template.substitute(**context)
97+ config = yaml.load(template.substitute(**context))
98+ if 'power_state' in config:
99+ del config['power_state']
100+ # Precise does not support cloud-init performing the reboot, so curtin
101+ # must have this statement.
102+ if node.distro_series == "precise":
103+ config['power_state'] = {'mode': 'reboot'}
104+ return yaml.dump(config)
105
106
107 def get_curtin_context(node, rack_controller=None):
108
109=== modified file 'src/maasserver/tests/test_compose_preseed.py'
110--- src/maasserver/tests/test_compose_preseed.py 2016-10-05 20:08:01 +0000
111+++ src/maasserver/tests/test_compose_preseed.py 2016-12-08 07:42:09 +0000
112@@ -311,6 +311,12 @@
113 preseed['datasource']['MAAS'],
114 KeysEqual(
115 'metadata_url', 'consumer_key', 'token_key', 'token_secret'))
116+ self.assertThat(
117+ preseed['power_state'], MatchesDict({
118+ 'delay': Equals('now'),
119+ 'mode': Equals('reboot'),
120+ 'timeout': Equals(1800),
121+ }))
122 self.assertEqual(
123 absolute_reverse('curtin-metadata'),
124 preseed['datasource']['MAAS']['metadata_url'])
125
126=== modified file 'src/maasserver/tests/test_preseed.py'
127--- src/maasserver/tests/test_preseed.py 2016-12-07 12:46:14 +0000
128+++ src/maasserver/tests/test_preseed.py 2016-12-08 07:42:09 +0000
129@@ -9,6 +9,7 @@
130 import json
131 import os
132 from pipes import quote
133+from textwrap import dedent
134 from unittest.mock import sentinel
135 from urllib.parse import urlparse
136
137@@ -863,12 +864,30 @@
138 config = get_curtin_config(node)
139 self.assertThat(
140 config,
141- ContainsAll(
142- [
143- 'mode: reboot',
144- "debconf_selections:",
145- ]
146- ))
147+ Contains("debconf_selections:"))
148+ self.assertThat(config, Not(Contains('mode: reboot')))
149+
150+ def test_get_curtin_config_removes_power_state(self):
151+ node = factory.make_Node_with_Interface_on_Subnet(
152+ primary_rack=self.rpc_rack_controller)
153+ self.configure_get_boot_images_for_node(node, 'xinstall')
154+ power_state_template = dedent("""\
155+ power_state:
156+ mode: reboot
157+ """)
158+ self.patch(preseed_module, "get_preseed_template").return_value = (
159+ factory.make_name("filename"), power_state_template)
160+ config = get_curtin_config(node)
161+ self.assertThat(config, Not(Contains('mode: reboot')))
162+
163+ def test_get_curtin_config_contains_reboot_for_precise(self):
164+ node = factory.make_Node_with_Interface_on_Subnet(
165+ primary_rack=self.rpc_rack_controller)
166+ node.distro_series = "precise"
167+ node.save()
168+ self.configure_get_boot_images_for_node(node, 'xinstall')
169+ config = get_curtin_config(node)
170+ self.assertThat(config, Contains('mode: reboot'))
171
172 def test_get_curtin_config_with_ipv4_rack_url(self):
173 primary_rack = self.rpc_rack_controller
174@@ -879,7 +898,6 @@
175 self.configure_get_boot_images_for_node(node, 'xinstall')
176 config = get_curtin_config(node)
177 yaml_conf = yaml.safe_load(config)
178- self.assertEqual('reboot', yaml_conf['power_state']['mode'])
179 self.assertEqual(
180 "%smetadata/latest/by-id/%s/" % (
181 primary_rack.url, node.system_id),
182@@ -895,7 +913,6 @@
183 self.configure_get_boot_images_for_node(node, 'xinstall')
184 config = get_curtin_config(node)
185 yaml_conf = yaml.safe_load(config)
186- self.assertEqual('reboot', yaml_conf['power_state']['mode'])
187 self.assertEqual(
188 "%smetadata/latest/by-id/%s/" % (
189 primary_rack.url, node.system_id),
190@@ -911,7 +928,6 @@
191 self.configure_get_boot_images_for_node(node, 'xinstall')
192 config = get_curtin_config(node)
193 yaml_conf = yaml.safe_load(config)
194- self.assertEqual('reboot', yaml_conf['power_state']['mode'])
195 self.assertEqual(
196 "%smetadata/latest/by-id/%s/" % (
197 primary_rack.url, node.system_id),
198@@ -927,7 +943,6 @@
199 self.configure_get_boot_images_for_node(node, 'xinstall')
200 config = get_curtin_config(node)
201 yaml_conf = yaml.safe_load(config)
202- self.assertEqual('reboot', yaml_conf['power_state']['mode'])
203 self.assertEqual(
204 "%smetadata/latest/by-id/%s/" % (primary_rack.url, node.system_id),
205 yaml_conf['late_commands']['maas'][2])