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
1=== modified file 'etc/maas/templates/deployment-user-data/maas_configure_interfaces.py'
2--- etc/maas/templates/deployment-user-data/maas_configure_interfaces.py 2015-05-07 18:14:38 +0000
3+++ etc/maas/templates/deployment-user-data/maas_configure_interfaces.py 2015-06-16 23:14:48 +0000
4@@ -26,7 +26,10 @@
5 __metaclass__ = type
6
7 from argparse import ArgumentParser
8-from errno import ENOENT
9+from errno import (
10+ ENOENT,
11+ ENOTDIR,
12+)
13 from logging import getLogger
14 from os import (
15 listdir,
16@@ -120,9 +123,9 @@
17 mac = read_file(
18 os.path.join('/sys/class/net', interface, 'address'))
19 except IOError as e:
20- # Tolerate file-not-found errors, to absorb any variability in
21- # the /sys/class/net API that doesn't concern us.
22- if e.errno != ENOENT:
23+ # Tolerate file or directory not found errors, to absorb any
24+ # variability in the /sys/class/net API that doesn't concern us.
25+ if e.errno != ENOENT and e.errno != ENOTDIR:
26 raise
27 else:
28 mac = normalise_mac(mac)