Merge lp:~andreserl/maas/lp1665143_2.1 into lp:maas/2.1

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: no longer in the source branch.
Merged at revision: 5591
Proposed branch: lp:~andreserl/maas/lp1665143_2.1
Merge into: lp:maas/2.1
Diff against target: 126 lines (+89/-1)
3 files modified
docs/changelog.rst (+2/-0)
src/provisioningserver/refresh/node_info_scripts.py (+7/-1)
src/provisioningserver/refresh/tests/test_node_info_scripts.py (+80/-0)
To merge this branch: bzr merge lp:~andreserl/maas/lp1665143_2.1
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Blake Rouse (community) Approve
Review via email: mp+318547@code.launchpad.net

Commit message

When discovering a block device, select the shortest by-id path link to the device.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) :
review: Needs Fixing
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Ah my bad, was looking at the diff wrong. I see you added another test. This makes since now.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.6 MiB)

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

Hit:1 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
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://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe Sources [134 kB]
Get:6 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [412 kB]
Get:7 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [156 kB]
Fetched 1,008 kB in 0s (1,692 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).
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 version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
pxelinux...

Revision history for this message
Andres Rodriguez (andreserl) wrote :

updated test, self approving!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/changelog.rst'
2--- docs/changelog.rst 2017-02-17 05:59:11 +0000
3+++ docs/changelog.rst 2017-03-02 01:57:37 +0000
4@@ -34,6 +34,8 @@
5
6 LP: #1665459 Fix anonymous auto-enlistment to properly detect rack-facing region IP address
7
8+LP: #1665143 Select the shortest by-id path when discovering block devices to address issues when discovering nvme devices.
9+
10
11 Other notable changes
12 ---------------------
13
14=== modified file 'src/provisioningserver/refresh/node_info_scripts.py'
15--- src/provisioningserver/refresh/node_info_scripts.py 2017-02-14 15:56:02 +0000
16+++ src/provisioningserver/refresh/node_info_scripts.py 2017-03-02 01:57:37 +0000
17@@ -276,11 +276,17 @@
18
19 def _path_to_idpath(path):
20 """Searches dev_disk_byid for a device symlinked to /dev/[path]"""
21+ shortest_link = None
22 if os.path.exists(dev_disk_byid):
23 for link in os.listdir(dev_disk_byid):
24 if os.path.exists(path) and os.path.samefile(
25 os.path.join(dev_disk_byid, link), path):
26- return os.path.join(dev_disk_byid, link)
27+ if shortest_link is None:
28+ shortest_link = link
29+ elif len(link) < len(shortest_link):
30+ shortest_link = link
31+ if shortest_link:
32+ return os.path.join(dev_disk_byid, shortest_link)
33 return None
34
35 # Grab the block devices from lsblk. Excludes RAM devices
36
37=== modified file 'src/provisioningserver/refresh/tests/test_node_info_scripts.py'
38--- src/provisioningserver/refresh/tests/test_node_info_scripts.py 2017-02-14 15:56:02 +0000
39+++ src/provisioningserver/refresh/tests/test_node_info_scripts.py 2017-03-02 01:57:37 +0000
40@@ -482,6 +482,86 @@
41 "RPM": "5400",
42 }], self.call_gather_physical_block_devices(byidroot))
43
44+ def test__returns_block_device_with_shortest_byidpath_long_first(self):
45+ name = factory.make_name('name')
46+ model = factory.make_name('model')
47+ serial = factory.make_name('serial')
48+ size = random.randint(3000 * 1000, 1000 * 1000 * 1000)
49+ block_size = random.choice([512, 1024, 4096])
50+ check_output = self.patch(subprocess, "check_output")
51+
52+ # Create simulated /dev tree
53+ devroot = self.make_dir()
54+ os.mkdir(os.path.join(devroot, 'disk'))
55+ byidroot = os.path.join(devroot, 'disk', 'by_id')
56+ os.mkdir(byidroot)
57+ os.mknod(os.path.join(devroot, name))
58+ os.symlink(os.path.join(devroot, name),
59+ os.path.join(byidroot, 'deviceid-long'))
60+ os.symlink(os.path.join(devroot, name),
61+ os.path.join(byidroot, 'deviceid'))
62+
63+ check_output.side_effect = [
64+ self.make_lsblk_output(name=name, model=model),
65+ self.make_udevadm_output(name, serial=serial, dev=devroot),
66+ b'%d' % size,
67+ b'%d' % block_size,
68+ ]
69+ self.assertEqual([{
70+ "NAME": name,
71+ "PATH": os.path.join(devroot, name),
72+ "ID_PATH": os.path.join(byidroot, 'deviceid'),
73+ "RO": "0",
74+ "RM": "0",
75+ "MODEL": model,
76+ "ROTA": "1",
77+ "SATA": "1",
78+ "SERIAL": serial,
79+ "SIZE": "%s" % size,
80+ "BLOCK_SIZE": "%s" % block_size,
81+ "RPM": "5400",
82+ }], self.call_gather_physical_block_devices(byidroot))
83+
84+ def test__returns_block_device_with_first_byidpath_long_second(self):
85+ name = factory.make_name('name')
86+ model = factory.make_name('model')
87+ serial = factory.make_name('serial')
88+ size = random.randint(3000 * 1000, 1000 * 1000 * 1000)
89+ block_size = random.choice([512, 1024, 4096])
90+ check_output = self.patch(subprocess, "check_output")
91+
92+ # Create simulated /dev tree
93+ devroot = self.make_dir()
94+ os.mkdir(os.path.join(devroot, 'disk'))
95+ byidroot = os.path.join(devroot, 'disk', 'by_id')
96+ os.mkdir(byidroot)
97+ os.mknod(os.path.join(devroot, name))
98+ os.symlink(os.path.join(devroot, name),
99+ os.path.join(byidroot, 'deviceid'))
100+ os.symlink(os.path.join(devroot, name),
101+ os.path.join(byidroot, 'deviceid-longest'))
102+
103+ check_output.side_effect = [
104+ self.make_lsblk_output(name=name, model=model),
105+ self.make_udevadm_output(name, serial=serial, dev=devroot),
106+ b'%d' % size,
107+ b'%d' % block_size,
108+ ]
109+ self.assertEqual([{
110+ "NAME": name,
111+ "PATH": os.path.join(devroot, name),
112+ "ID_PATH": os.path.join(byidroot, 'deviceid'),
113+ "RO": "0",
114+ "RM": "0",
115+ "MODEL": model,
116+ "ROTA": "1",
117+ "SATA": "1",
118+ "SERIAL": serial,
119+ "SIZE": "%s" % size,
120+ "BLOCK_SIZE": "%s" % block_size,
121+ "RPM": "5400",
122+ }], self.call_gather_physical_block_devices(byidroot))
123+
124 def test__removes_duplicate_block_device_same_serial_and_model(self):
125 """Multipath disks get multiple IDs, but same serial/model is same
126 device and should only be enumerated once."""

Subscribers

People subscribed via source and target branches