SHA256
1
0
forked from pool/cloud-init

Accepting request 699769 from Cloud:Tools

- Update cloud-init-write-routes.patch (bsc#1132692)
  + Properly accumulate all the defined routes for a given network device.
    Previously only the last defined route was written to the routes file.

- Update cloud-init-trigger-udev.patch (bsc#1125950)
  + Write the udev rules to a different file than the default
  + Settle udev if not all configured devices are in the device tree to
    avoid race condition between udev and cloud-init

  + Fix the order of calls, the SUSE implementation of route config file

OBS-URL: https://build.opensuse.org/request/show/699769
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cloud-init?expand=0&rev=58
This commit is contained in:
Dominique Leuenberger 2019-05-03 20:23:07 +00:00 committed by Git OBS Bridge
commit a88363e6e1
3 changed files with 47 additions and 31 deletions

View File

@ -1,35 +1,36 @@
--- cloudinit/net/sysconfig.py.orig
+++ cloudinit/net/sysconfig.py
@@ -15,6 +15,7 @@ from .network_state import (
is_ipv6_addr, net_prefix_to_ipv4_mask, subnet_is_ipv6)
@@ -8,6 +8,7 @@ import six
from cloudinit.distros.parsers import networkmanager_conf
from cloudinit.distros.parsers import resolv_conf
from cloudinit import log as logging
+from cloudinit import net
from cloudinit import util
LOG = logging.getLogger(__name__)
+PERS_NET_RULES_DEFAULT = 'etc/udev/rules.d/70-persistent-net.rules'
def _make_header(sep='#'):
@@ -276,7 +277,7 @@ class Renderer(renderer.Renderer):
config = {}
self.sysconf_dir = config.get('sysconf_dir', 'etc/sysconfig')
self.netrules_path = config.get(
- 'netrules_path', 'etc/udev/rules.d/70-persistent-net.rules')
+ 'netrules_path', PERS_NET_RULES_DEFAULT)
self.dns_path = config.get('dns_path', 'etc/resolv.conf')
nm_conf_path = 'etc/NetworkManager/conf.d/99-cloud-init.conf'
self.networkmanager_conf_path = config.get('networkmanager_conf_path',
@@ -676,6 +677,15 @@ class Renderer(renderer.Renderer):
from . import renderer
@@ -673,6 +674,14 @@ class Renderer(renderer.Renderer):
if nm_conf_content:
util.write_file(nm_conf_path, nm_conf_content, file_mode)
if self.netrules_path:
+ # When many interfaces are present it can happen that we get here
+ # before they are all setup. Settle if that is the case.
+ for iface in network_state.iter_interfaces(
+ renderer.filter_by_physical):
+ path = net.sys_dev_path(str(iface))
+ if not os.path.exists(path):
+ util.udevadm_settle(path, 5)
+ break
netrules_content = self._render_persistent_net(network_state)
netrules_path = util.target_path(target, self.netrules_path)
util.write_file(netrules_path, netrules_content, file_mode)
+ # Making the assumption that the configured file is in a sane
+ # location
+ if (
+ os.path.basename(PERS_NET_RULES_DEFAULT)
+ != os.path.basename(netrules_path)
+ ):
+ util.subp(
+ ['udevadm', 'trigger', '-a ACTION=add', '-a SUBSYSTEM=net']
+ )
sysconfig_path = util.target_path(target, templates.get('control'))
# Distros configuring /etc/sysconfig/network as a file e.g. Centos
--- cloudinit/distros/opensuse.py.orig
+++ cloudinit/distros/opensuse.py
@@ -38,6 +38,8 @@ class Distro(distros.Distro):
'sysconfig': {
'control': 'etc/sysconfig/network/config',
'iface_templates': '%(base)s/network/ifcfg-%(name)s',
+ 'netrules_path': (
+ 'etc/udev/rules.d/85-persistent-net-cloud-init.rules'),
'route_templates': {
'ipv4': '%(base)s/network/ifroute-%(name)s',
'ipv6': '%(base)s/network/ifroute-%(name)s',

View File

@ -22,9 +22,9 @@
+ for config in device_configs:
+ if_name = config.get('name')
+ subnets = config.get('subnets', [])
+ config_routes = ''
+ for subnet in subnets:
+ routes = subnet.get('routes', [])
+ config_routes = ''
+ for route in routes:
+ dest = route.get('network')
+ if dest in default_nets:

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Wed Apr 24 18:37:32 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
- Update cloud-init-write-routes.patch (bsc#1132692)
+ Properly accumulate all the defined routes for a given network device.
Previously only the last defined route was written to the routes file.
-------------------------------------------------------------------
Sat Mar 30 12:42:27 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
- Update cloud-init-trigger-udev.patch (bsc#1125950)
+ Write the udev rules to a different file than the default
+ Settle udev if not all configured devices are in the device tree to
avoid race condition between udev and cloud-init
-------------------------------------------------------------------
Fri Feb 22 22:11:20 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
@ -9,7 +24,7 @@ Fri Feb 22 22:11:20 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
Fri Feb 22 16:20:28 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
- Modify cloud-init-write-routes.patch (bsc#1125992)
+ Fix the order of calls, the SUSE imaplementation of route config file
+ Fix the order of calls, the SUSE implementation of route config file
writing must clobber the default implementation.
-------------------------------------------------------------------