Use if index to assign DigitalOcean IPv4 LL addrs

Systemd's interface naming makes assigning link-local addresses to the
interface that a DigitalOcean guest may use to obtain metadata
unreliables, so instead, we select which one to assign the address to
based on its index instead.

https://bugzilla.redhat.com/show_bug.cgi?id=1442463
https://git.launchpad.net/cloud-init/commit/?id=dad97585be0f30202a5a351800f20d4432b94694
This commit is contained in:
Garrett Holmstrom 2017-04-14 15:11:41 -07:00
parent 8939822a56
commit e3d962ecb4
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,32 @@
Index: cloud-init-0.7.9/cloudinit/sources/helpers/digitalocean.py
===================================================================
--- cloud-init-0.7.9.orig/cloudinit/sources/helpers/digitalocean.py
+++ cloud-init-0.7.9/cloudinit/sources/helpers/digitalocean.py
@@ -23,11 +23,8 @@ def assign_ipv4_link_local(nic=None):
"""
if not nic:
- for cdev in sorted(cloudnet.get_devicelist()):
- if cloudnet.is_physical(cdev):
- nic = cdev
- LOG.debug("assigned nic '%s' for link-local discovery", nic)
- break
+ nic = get_link_local_nic()
+ LOG.debug("selected interface '%s' for reading metadata", nic)
if not nic:
raise RuntimeError("unable to find interfaces to access the"
@@ -57,6 +54,13 @@ def assign_ipv4_link_local(nic=None):
return nic
+def get_link_local_nic():
+ nics = [f for f in cloudnet.get_devicelist() if cloudnet.is_physical(f)]
+ if not nics:
+ return None
+ return min(nics, key=lambda d: cloudnet.read_sys_net_int(d, 'ifindex'))
+
+
def del_ipv4_link_local(nic=None):
"""Remove the ip4LL address. While this is not necessary, the ip4LL
address is extraneous and confusing to users.

View File

@ -88,7 +88,13 @@ Patch20: cloud-init-0.7.9-digitalocean-loopback.patch
# Configure all NICs presented in DigitalOcean metadata
# https://bugzilla.redhat.com/show_bug.cgi?id=1442463
# https://git.launchpad.net/cloud-init/commit/?id=ff44056771416cb811879b13b97f88d8f2057071
Patch21: quilt_patches/cloud-init-0.7.9-digitalocean-all-nics.patch
Patch21: cloud-init-0.7.9-digitalocean-all-nics.patch
# Make DigitalOcean use interface indexes, not names, to choose which one
# to assign the link-local address used for metadata
# https://bugzilla.redhat.com/show_bug.cgi?id=1442463
# https://git.launchpad.net/cloud-init/commit/?id=dad97585be0f30202a5a351800f20d4432b94694
Patch22: cloud-init-0.7.9-digitalocean-ifindex.patch
BuildArch: noarch
@ -225,6 +231,7 @@ nosetests-%{python3_version} tests/unittests/
* Fri Apr 14 2017 Garrett Holmstrom <gholms@fedoraproject.org> - 0.7.9-5
- Made DigitalOcean DNS server handling consistent with OpenStack [RH:1442463, LP:1675571]
- Improved handling of multiple NICs on DigitalOcean [RH:1442463]
- Assign link-local IPV4 addresses in DigitalOcean based on interface indexes [RH:1442463]
* Tue Mar 14 2017 Garrett Holmstrom <gholms@fedoraproject.org> - 0.7.9-4
- Fixed systemd dependency cycle with cloud-final and os-collect-config [RH:1420946, RH:1428492]