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
=== modified file 'docs/changelog.rst'
--- docs/changelog.rst 2017-02-17 05:59:11 +0000
+++ docs/changelog.rst 2017-03-02 01:57:37 +0000
@@ -34,6 +34,8 @@
3434
35LP: #1665459 Fix anonymous auto-enlistment to properly detect rack-facing region IP address35LP: #1665459 Fix anonymous auto-enlistment to properly detect rack-facing region IP address
3636
37LP: #1665143 Select the shortest by-id path when discovering block devices to address issues when discovering nvme devices.
38
3739
38Other notable changes40Other notable changes
39---------------------41---------------------
4042
=== modified file 'src/provisioningserver/refresh/node_info_scripts.py'
--- src/provisioningserver/refresh/node_info_scripts.py 2017-02-14 15:56:02 +0000
+++ src/provisioningserver/refresh/node_info_scripts.py 2017-03-02 01:57:37 +0000
@@ -276,11 +276,17 @@
276276
277 def _path_to_idpath(path):277 def _path_to_idpath(path):
278 """Searches dev_disk_byid for a device symlinked to /dev/[path]"""278 """Searches dev_disk_byid for a device symlinked to /dev/[path]"""
279 shortest_link = None
279 if os.path.exists(dev_disk_byid):280 if os.path.exists(dev_disk_byid):
280 for link in os.listdir(dev_disk_byid):281 for link in os.listdir(dev_disk_byid):
281 if os.path.exists(path) and os.path.samefile(282 if os.path.exists(path) and os.path.samefile(
282 os.path.join(dev_disk_byid, link), path):283 os.path.join(dev_disk_byid, link), path):
283 return os.path.join(dev_disk_byid, link)284 if shortest_link is None:
285 shortest_link = link
286 elif len(link) < len(shortest_link):
287 shortest_link = link
288 if shortest_link:
289 return os.path.join(dev_disk_byid, shortest_link)
284 return None290 return None
285291
286 # Grab the block devices from lsblk. Excludes RAM devices292 # Grab the block devices from lsblk. Excludes RAM devices
287293
=== modified file 'src/provisioningserver/refresh/tests/test_node_info_scripts.py'
--- src/provisioningserver/refresh/tests/test_node_info_scripts.py 2017-02-14 15:56:02 +0000
+++ src/provisioningserver/refresh/tests/test_node_info_scripts.py 2017-03-02 01:57:37 +0000
@@ -482,6 +482,86 @@
482 "RPM": "5400",482 "RPM": "5400",
483 }], self.call_gather_physical_block_devices(byidroot))483 }], self.call_gather_physical_block_devices(byidroot))
484484
485 def test__returns_block_device_with_shortest_byidpath_long_first(self):
486 name = factory.make_name('name')
487 model = factory.make_name('model')
488 serial = factory.make_name('serial')
489 size = random.randint(3000 * 1000, 1000 * 1000 * 1000)
490 block_size = random.choice([512, 1024, 4096])
491 check_output = self.patch(subprocess, "check_output")
492
493 # Create simulated /dev tree
494 devroot = self.make_dir()
495 os.mkdir(os.path.join(devroot, 'disk'))
496 byidroot = os.path.join(devroot, 'disk', 'by_id')
497 os.mkdir(byidroot)
498 os.mknod(os.path.join(devroot, name))
499 os.symlink(os.path.join(devroot, name),
500 os.path.join(byidroot, 'deviceid-long'))
501 os.symlink(os.path.join(devroot, name),
502 os.path.join(byidroot, 'deviceid'))
503
504 check_output.side_effect = [
505 self.make_lsblk_output(name=name, model=model),
506 self.make_udevadm_output(name, serial=serial, dev=devroot),
507 b'%d' % size,
508 b'%d' % block_size,
509 ]
510 self.assertEqual([{
511 "NAME": name,
512 "PATH": os.path.join(devroot, name),
513 "ID_PATH": os.path.join(byidroot, 'deviceid'),
514 "RO": "0",
515 "RM": "0",
516 "MODEL": model,
517 "ROTA": "1",
518 "SATA": "1",
519 "SERIAL": serial,
520 "SIZE": "%s" % size,
521 "BLOCK_SIZE": "%s" % block_size,
522 "RPM": "5400",
523 }], self.call_gather_physical_block_devices(byidroot))
524
525 def test__returns_block_device_with_first_byidpath_long_second(self):
526 name = factory.make_name('name')
527 model = factory.make_name('model')
528 serial = factory.make_name('serial')
529 size = random.randint(3000 * 1000, 1000 * 1000 * 1000)
530 block_size = random.choice([512, 1024, 4096])
531 check_output = self.patch(subprocess, "check_output")
532
533 # Create simulated /dev tree
534 devroot = self.make_dir()
535 os.mkdir(os.path.join(devroot, 'disk'))
536 byidroot = os.path.join(devroot, 'disk', 'by_id')
537 os.mkdir(byidroot)
538 os.mknod(os.path.join(devroot, name))
539 os.symlink(os.path.join(devroot, name),
540 os.path.join(byidroot, 'deviceid'))
541 os.symlink(os.path.join(devroot, name),
542 os.path.join(byidroot, 'deviceid-longest'))
543
544 check_output.side_effect = [
545 self.make_lsblk_output(name=name, model=model),
546 self.make_udevadm_output(name, serial=serial, dev=devroot),
547 b'%d' % size,
548 b'%d' % block_size,
549 ]
550 self.assertEqual([{
551 "NAME": name,
552 "PATH": os.path.join(devroot, name),
553 "ID_PATH": os.path.join(byidroot, 'deviceid'),
554 "RO": "0",
555 "RM": "0",
556 "MODEL": model,
557 "ROTA": "1",
558 "SATA": "1",
559 "SERIAL": serial,
560 "SIZE": "%s" % size,
561 "BLOCK_SIZE": "%s" % block_size,
562 "RPM": "5400",
563 }], self.call_gather_physical_block_devices(byidroot))
564
485 def test__removes_duplicate_block_device_same_serial_and_model(self):565 def test__removes_duplicate_block_device_same_serial_and_model(self):
486 """Multipath disks get multiple IDs, but same serial/model is same566 """Multipath disks get multiple IDs, but same serial/model is same
487 device and should only be enumerated once."""567 device and should only be enumerated once."""

Subscribers

People subscribed via source and target branches