Getting this to trip is somewhat tricky and racy due to how fast/slow
the bond is able to come up.  However, if the bond is up before cloud-
init.service runs it's net.apply_network_config_names() then we see the
following:


>>> r = net._get_current_rename_info(check_downable=True)
>>> r
{False: {'up': False, 'name': 'bonding_masters', 'downable': True}, 
'00:00:00:00:00:00': {'up': True, 'name': 'lo', 'downable': False}, 
'52:54:00:12:34:02': {'up': True, 'name': 'interface1', 'downable': True}, 
'52:54:00:12:34:00': {'up': False, 'name': 'bond0', 'downable': True}}
>>> r.keys()
dict_keys([False, '00:00:00:00:00:00', '52:54:00:12:34:02', 
'52:54:00:12:34:00'])
>>> r['52:54:00:12:34:00']
{'up': False, 'name': 'bond0', 'downable': True}
>>> r['52:54:00:12:34:02']
{'up': True, 'name': 'interface1', 'downable': True}


Here we can see that by checking /sys/class/net/* for interfaces and mapping a 
mac address to an interface picks up bond0 for 'interface0's mac.

Then if we attempt to apply the names, we see the error:

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> ncfg = yaml.load(open('/root/network-config'))
>>> netcfg = ncfg.get('network')
>>> netcfg
>>> ncfg.keys()
dict_keys(['version', 'config'])
>>> from cloudinit import net
>>> net.apply_network_config_names(ncfg)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 201, in 
apply_network_config_names
    return _rename_interfaces(renames)
  File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 336, in 
_rename_interfaces
    raise Exception('\n'.join(errors))
Exception: [unknown] Error performing rename('bond0', 'interface0') for 
52:54:00:12:34:00, interface0: Unexpected error while running command.
Command: ['ip', 'link', 'set', 'bond0', 'name', 'interface0']
Exit code: 2
Reason: -
Stdout: -
Stderr: RTNETLINK answers: File exists

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1669860

Title:
  cloud-init attempts to rename bonds

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1669860/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to