Merge lp:~ltrager/maas/lp1637401_2.1 into lp:maas/2.1

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 5559
Proposed branch: lp:~ltrager/maas/lp1637401_2.1
Merge into: lp:maas/2.1
Diff against target: 127 lines (+34/-20)
2 files modified
src/provisioningserver/drivers/hardware/tests/test_virsh.py (+23/-13)
src/provisioningserver/drivers/hardware/virsh.py (+11/-7)
To merge this branch: bzr merge lp:~ltrager/maas/lp1637401_2.1
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+312212@code.launchpad.net

Commit message

Backport r5579 from trunk: During probe and enlist of virsh only power off and commission new nodes.

Previously probe_virsh_and_enlist would power off each node before requesting a new node row was created. If the machine already exists or there was some issue creating the new node row the node was still powered off. This meant reprobing a virsh host would power off all known nodes. Power off now only happens if a new row was successfully created, existing nodes are ignored and left untouched.

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.5 MiB)

The attempt to merge lp:~ltrager/maas/lp1637401_2.1 into lp:maas/2.1 failed. Below is the output from the failed tests.

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security/main Sources [50.6 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [181 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [64.0 kB]
Get:8 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/main Sources [207 kB]
Get:9 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [429 kB]
Get:10 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [166 kB]
Get:11 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [366 kB]
Fetched 1,770 kB in 0s (2,413 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 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).
freeipmi-tools is already the newest version (1.4.11-1ubu...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/drivers/hardware/tests/test_virsh.py'
2--- src/provisioningserver/drivers/hardware/tests/test_virsh.py 2016-05-12 19:07:37 +0000
3+++ src/provisioningserver/drivers/hardware/tests/test_virsh.py 2016-11-30 23:24:27 +0000
4@@ -13,9 +13,7 @@
5 from lxml import etree
6 from maastesting.factory import factory
7 from maastesting.matchers import (
8- MockAnyCall,
9 MockCalledOnceWith,
10- MockCalledWith,
11 MockCallsMatch,
12 )
13 from maastesting.testcase import (
14@@ -267,7 +265,7 @@
15 # with some fake architectures.
16 user = factory.make_name('user')
17 system_id = factory.make_name('system_id')
18- machines = [factory.make_name('machine') for _ in range(4)]
19+ machines = [factory.make_name('machine') for _ in range(5)]
20 self.patch(virsh.VirshSSH, 'list').return_value = machines
21 fake_arch = factory.make_name('arch')
22 mock_arch = self.patch(virsh.VirshSSH, 'get_arch')
23@@ -281,6 +279,7 @@
24 virsh.VirshVMState.OFF,
25 virsh.VirshVMState.OFF,
26 virsh.VirshVMState.ON,
27+ virsh.VirshVMState.ON,
28 ]
29 mock_state = self.patch(virsh.VirshSSH, 'get_state')
30 mock_state.side_effect = fake_states
31@@ -310,7 +309,7 @@
32 mock_poweroff = self.patch(virsh.VirshSSH, 'poweroff')
33 mock_create_node = self.patch(virsh, 'create_node')
34 mock_create_node.side_effect = asynchronous(
35- lambda *args, **kwargs: system_id)
36+ lambda *args, **kwargs: None if machines[4] in args else system_id)
37 mock_commission_node = self.patch(virsh, 'commission_node')
38
39 # Patch login and logout so that we don't really contact
40@@ -324,6 +323,7 @@
41 SAMPLE_DUMPXML_2,
42 SAMPLE_DUMPXML_3,
43 SAMPLE_DUMPXML_4,
44+ SAMPLE_DUMPXML,
45 ]
46
47 mock_run = self.patch(virsh.VirshSSH, 'run')
48@@ -339,12 +339,6 @@
49 self.expectThat(
50 mock_login, MockCalledOnceWith(poweraddr, fake_password))
51
52- # The first and last machine should have poweroff called on it, as it
53- # was initial in the on state.
54- self.expectThat(mock_poweroff, MockAnyCall(machines[0]))
55-
56- self.expectThat(mock_poweroff, MockAnyCall(machines[3]))
57-
58 # Check that the create command had the correct parameters for
59 # each machine.
60 self.expectThat(
61@@ -361,11 +355,27 @@
62 call(
63 fake_macs[3], fake_arch, 'virsh', called_params[3],
64 domain, machines[3]),
65- ))
66+ call(
67+ fake_macs[4], fake_arch, 'virsh', called_params[4],
68+ domain, machines[4]),
69+ ))
70+
71+ # The first and last machine should have poweroff called on it, as it
72+ # was initial in the on state.
73+ self.expectThat(
74+ mock_poweroff, MockCallsMatch(
75+ call(machines[0]),
76+ call(machines[3]),
77+ ))
78+
79 self.assertThat(mock_logout, MockCalledOnceWith())
80 self.expectThat(
81- mock_commission_node,
82- MockCalledWith(system_id, user))
83+ mock_commission_node, MockCallsMatch(
84+ call(system_id, user),
85+ call(system_id, user),
86+ call(system_id, user),
87+ call(system_id, user),
88+ ))
89
90 @inlineCallbacks
91 def test_probe_and_enlist_login_failure(self):
92
93=== modified file 'src/provisioningserver/drivers/hardware/virsh.py'
94--- src/provisioningserver/drivers/hardware/virsh.py 2016-05-12 19:07:37 +0000
95+++ src/provisioningserver/drivers/hardware/virsh.py 2016-11-30 23:24:27 +0000
96@@ -282,11 +282,6 @@
97 state = conn.get_state(machine)
98 macs = conn.get_mac_addresses(machine)
99
100- # Force the machine off, as MAAS will control the machine
101- # and it needs to be in a known state of off.
102- if state == VirshVMState.ON:
103- conn.poweroff(machine)
104-
105 params = {
106 'power_address': poweraddr,
107 'power_id': machine,
108@@ -296,8 +291,17 @@
109 system_id = create_node(
110 macs, arch, 'virsh', params, domain, machine).wait(30)
111
112- if system_id is not None:
113- conn.configure_pxe_boot(machine)
114+ # If the system_id is None an error occured when creating the machine.
115+ # Most likely the error is the node already exists.
116+ if system_id is None:
117+ continue
118+
119+ # Force the machine off, as MAAS will control the machine
120+ # and it needs to be in a known state of off.
121+ if state == VirshVMState.ON:
122+ conn.poweroff(machine)
123+
124+ conn.configure_pxe_boot(machine)
125
126 if accept_all:
127 commission_node(system_id, user).wait(30)

Subscribers

People subscribed via source and target branches

to all changes: