Merge lp:~mpontillo/maas/fix-map-interfaces-by-mac-failure-with-bond-driver-loaded into lp:~maas-committers/maas/trunk

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 4025
Proposed branch: lp:~mpontillo/maas/fix-map-interfaces-by-mac-failure-with-bond-driver-loaded
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 28 lines (+7/-4)
1 file modified
etc/maas/templates/deployment-user-data/maas_configure_interfaces.py (+7/-4)
To merge this branch: bzr merge lp:~mpontillo/maas/fix-map-interfaces-by-mac-failure-with-bond-driver-loaded
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+262154@code.launchpad.net

Commit message

Make map_interfaces_by_mac() more robust by ignoring files in /sys/class/net (objects that do not represent interfaces are not directories)

Description of the change

The unit tests fail as follows when the bonding driver is loaded, and no bond interfaces are configured:

http://paste.ubuntu.com/11727748/

I'm not certain, but I think this may fail in production if the bonding driver is loaded. If so, this is a critical bug that should be backported to 1.8.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Looks good, defensive programming FTW. Can you confirm that this is indeed a critical bug? Tweak the preseed to load the bonding driver and make sure the deploy fails. If it fails (and this fixes the problem), let's file a critical bug, add a mention to the 1.8.0 changelog and backport this to 1.8.

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

I think we want to get 1.8 out of the door right now so, if this is confirmed, let's target 1.8.1.

Revision history for this message
Mike Pontillo (mpontillo) wrote :

Yeah, let me land this and then look into that for the 1.8 version of this branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'etc/maas/templates/deployment-user-data/maas_configure_interfaces.py'
--- etc/maas/templates/deployment-user-data/maas_configure_interfaces.py 2015-05-07 18:14:38 +0000
+++ etc/maas/templates/deployment-user-data/maas_configure_interfaces.py 2015-06-16 23:14:48 +0000
@@ -26,7 +26,10 @@
26__metaclass__ = type26__metaclass__ = type
2727
28from argparse import ArgumentParser28from argparse import ArgumentParser
29from errno import ENOENT29from errno import (
30 ENOENT,
31 ENOTDIR,
32)
30from logging import getLogger33from logging import getLogger
31from os import (34from os import (
32 listdir,35 listdir,
@@ -120,9 +123,9 @@
120 mac = read_file(123 mac = read_file(
121 os.path.join('/sys/class/net', interface, 'address'))124 os.path.join('/sys/class/net', interface, 'address'))
122 except IOError as e:125 except IOError as e:
123 # Tolerate file-not-found errors, to absorb any variability in126 # Tolerate file or directory not found errors, to absorb any
124 # the /sys/class/net API that doesn't concern us.127 # variability in the /sys/class/net API that doesn't concern us.
125 if e.errno != ENOENT:128 if e.errno != ENOENT and e.errno != ENOTDIR:
126 raise129 raise
127 else:130 else:
128 mac = normalise_mac(mac)131 mac = normalise_mac(mac)