From 252d83a12a3e127d6c88b2a563f5f634d5d407eb Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 27 2020 18:08:40 +0000 Subject: import cloud-init-20.3-5.el8 --- diff --git a/SOURCES/ci-network-Fix-type-and-respect-name-when-rendering-vla.patch b/SOURCES/ci-network-Fix-type-and-respect-name-when-rendering-vla.patch new file mode 100644 index 0000000..a2ef2dc --- /dev/null +++ b/SOURCES/ci-network-Fix-type-and-respect-name-when-rendering-vla.patch @@ -0,0 +1,247 @@ +From 51a90ecbdf1f3900183d8ec641eeb4571decf6dc Mon Sep 17 00:00:00 2001 +From: Eduardo Otubo +Date: Wed, 4 Nov 2020 12:37:54 +0100 +Subject: [PATCH] network: Fix type and respect name when rendering vlan in + sysconfig. (#541) + +RH-Author: Eduardo Terrell Ferrari Otubo (eterrell) +RH-MergeRequest: 19: network: Fix type and respect name when rendering vlan in sysconfig. (#541) +RH-Commit: [1/1] 75bea46017397082c5763125a5f35806c2f840e9 (eterrell/cloud-init) +RH-Bugzilla: 1881462 + +commit 8439b191ec2f336d544cab86dba2860f969cd5b8 +Author: Eduardo Otubo +Date: Tue Sep 15 18:00:00 2020 +0200 + + network: Fix type and respect name when rendering vlan in sysconfig. (#541) + + Prior to this change, vlans were rendered in sysconfig with + 'TYPE=Ethernet', and incorrectly rendered the PHYSDEV based on + the name of the vlan device rather than the 'link' provided + in the network config. + + The change here fixes: + * rendering of TYPE=Ethernet for a vlan + * adds a warning if the configured device name is not supported + per the RHEL 7 docs "11.5. Naming Scheme for VLAN Interfaces" + + LP: #1788915 + LP: #1826608 + RHBZ: #1861871 + +Signed-off-by: Eduardo Otubo +--- + cloudinit/net/sysconfig.py | 32 +++++++++- + tests/unittests/test_distros/test_netconfig.py | 81 ++++++++++++++++++++++++++ + tests/unittests/test_net.py | 4 -- + 3 files changed, 112 insertions(+), 5 deletions(-) + +diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py +index c078898..078636a 100644 +--- a/cloudinit/net/sysconfig.py ++++ b/cloudinit/net/sysconfig.py +@@ -99,6 +99,10 @@ class ConfigMap(object): + def __len__(self): + return len(self._conf) + ++ def skip_key_value(self, key, val): ++ """Skip the pair key, value if it matches a certain rule.""" ++ return False ++ + def to_string(self): + buf = io.StringIO() + buf.write(_make_header()) +@@ -106,6 +110,8 @@ class ConfigMap(object): + buf.write("\n") + for key in sorted(self._conf.keys()): + value = self._conf[key] ++ if self.skip_key_value(key, value): ++ continue + if isinstance(value, bool): + value = self._bool_map[value] + if not isinstance(value, str): +@@ -214,6 +220,7 @@ class NetInterface(ConfigMap): + 'bond': 'Bond', + 'bridge': 'Bridge', + 'infiniband': 'InfiniBand', ++ 'vlan': 'Vlan', + } + + def __init__(self, iface_name, base_sysconf_dir, templates, +@@ -267,6 +274,11 @@ class NetInterface(ConfigMap): + c.routes = self.routes.copy() + return c + ++ def skip_key_value(self, key, val): ++ if key == 'TYPE' and val == 'Vlan': ++ return True ++ return False ++ + + class Renderer(renderer.Renderer): + """Renders network information in a /etc/sysconfig format.""" +@@ -701,7 +713,16 @@ class Renderer(renderer.Renderer): + iface_cfg['ETHERDEVICE'] = iface_name[:iface_name.rfind('.')] + else: + iface_cfg['VLAN'] = True +- iface_cfg['PHYSDEV'] = iface_name[:iface_name.rfind('.')] ++ iface_cfg.kind = 'vlan' ++ ++ rdev = iface['vlan-raw-device'] ++ supported = _supported_vlan_names(rdev, iface['vlan_id']) ++ if iface_name not in supported: ++ LOG.info( ++ "Name '%s' for vlan '%s' is not officially supported" ++ "by RHEL. Supported: %s", ++ iface_name, rdev, ' '.join(supported)) ++ iface_cfg['PHYSDEV'] = rdev + + iface_subnets = iface.get("subnets", []) + route_cfg = iface_cfg.routes +@@ -909,6 +930,15 @@ class Renderer(renderer.Renderer): + "\n".join(netcfg) + "\n", file_mode) + + ++def _supported_vlan_names(rdev, vid): ++ """Return list of supported names for vlan devices per RHEL doc ++ 11.5. Naming Scheme for VLAN Interfaces.""" ++ return [ ++ v.format(rdev=rdev, vid=int(vid)) ++ for v in ("{rdev}{vid:04}", "{rdev}{vid}", ++ "{rdev}.{vid:04}", "{rdev}.{vid}")] ++ ++ + def available(target=None): + sysconfig = available_sysconfig(target=target) + nm = available_nm(target=target) +diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py +index f9fc3a1..a1df066 100644 +--- a/tests/unittests/test_distros/test_netconfig.py ++++ b/tests/unittests/test_distros/test_netconfig.py +@@ -541,6 +541,87 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): + V1_NET_CFG_IPV6, + expected_cfgs=expected_cfgs.copy()) + ++ def test_vlan_render_unsupported(self): ++ """Render officially unsupported vlan names.""" ++ cfg = { ++ 'version': 2, ++ 'ethernets': { ++ 'eth0': {'addresses': ["192.10.1.2/24"], ++ 'match': {'macaddress': "00:16:3e:60:7c:df"}}}, ++ 'vlans': { ++ 'infra0': {'addresses': ["10.0.1.2/16"], ++ 'id': 1001, 'link': 'eth0'}}, ++ } ++ expected_cfgs = { ++ self.ifcfg_path('eth0'): dedent("""\ ++ BOOTPROTO=none ++ DEVICE=eth0 ++ HWADDR=00:16:3e:60:7c:df ++ IPADDR=192.10.1.2 ++ NETMASK=255.255.255.0 ++ NM_CONTROLLED=no ++ ONBOOT=yes ++ TYPE=Ethernet ++ USERCTL=no ++ """), ++ self.ifcfg_path('infra0'): dedent("""\ ++ BOOTPROTO=none ++ DEVICE=infra0 ++ IPADDR=10.0.1.2 ++ NETMASK=255.255.0.0 ++ NM_CONTROLLED=no ++ ONBOOT=yes ++ PHYSDEV=eth0 ++ USERCTL=no ++ VLAN=yes ++ """), ++ self.control_path(): dedent("""\ ++ NETWORKING=yes ++ """), ++ } ++ self._apply_and_verify( ++ self.distro.apply_network_config, cfg, ++ expected_cfgs=expected_cfgs) ++ ++ def test_vlan_render(self): ++ cfg = { ++ 'version': 2, ++ 'ethernets': { ++ 'eth0': {'addresses': ["192.10.1.2/24"]}}, ++ 'vlans': { ++ 'eth0.1001': {'addresses': ["10.0.1.2/16"], ++ 'id': 1001, 'link': 'eth0'}}, ++ } ++ expected_cfgs = { ++ self.ifcfg_path('eth0'): dedent("""\ ++ BOOTPROTO=none ++ DEVICE=eth0 ++ IPADDR=192.10.1.2 ++ NETMASK=255.255.255.0 ++ NM_CONTROLLED=no ++ ONBOOT=yes ++ TYPE=Ethernet ++ USERCTL=no ++ """), ++ self.ifcfg_path('eth0.1001'): dedent("""\ ++ BOOTPROTO=none ++ DEVICE=eth0.1001 ++ IPADDR=10.0.1.2 ++ NETMASK=255.255.0.0 ++ NM_CONTROLLED=no ++ ONBOOT=yes ++ PHYSDEV=eth0 ++ USERCTL=no ++ VLAN=yes ++ """), ++ self.control_path(): dedent("""\ ++ NETWORKING=yes ++ """), ++ } ++ self._apply_and_verify( ++ self.distro.apply_network_config, cfg, ++ expected_cfgs=expected_cfgs) ++ + + class TestNetCfgDistroOpensuse(TestNetCfgDistroBase): + +diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py +index d7a7a65..c033745 100644 +--- a/tests/unittests/test_net.py ++++ b/tests/unittests/test_net.py +@@ -1656,7 +1656,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true + DHCLIENT_SET_DEFAULT_ROUTE=no + ONBOOT=yes + PHYSDEV=bond0 +- TYPE=Ethernet + USERCTL=no + VLAN=yes"""), + 'ifcfg-br0': textwrap.dedent("""\ +@@ -1699,7 +1698,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true + NETMASK1=255.255.255.0 + ONBOOT=yes + PHYSDEV=eth0 +- TYPE=Ethernet + USERCTL=no + VLAN=yes"""), + 'ifcfg-eth1': textwrap.dedent("""\ +@@ -2302,7 +2300,6 @@ iface bond0 inet6 static + NETMASK1=255.255.255.0 + ONBOOT=yes + PHYSDEV=en0 +- TYPE=Ethernet + USERCTL=no + VLAN=yes"""), + }, +@@ -3409,7 +3406,6 @@ USERCTL=no + NM_CONTROLLED=no + ONBOOT=yes + PHYSDEV=eno1 +- TYPE=Ethernet + USERCTL=no + VLAN=yes + """) +-- +1.8.3.1 + diff --git a/SPECS/cloud-init.spec b/SPECS/cloud-init.spec index 4c4428c..9ff9ace 100644 --- a/SPECS/cloud-init.spec +++ b/SPECS/cloud-init.spec @@ -6,7 +6,7 @@ Name: cloud-init Version: 20.3 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Cloud instance init scripts Group: System Environment/Base @@ -24,6 +24,8 @@ Patch0006: 0006-include-NOZEROCONF-yes-in-etc-sysconfig-network.patch Patch0007: 0007-Remove-race-condition-between-cloud-init-and-Network.patch Patch8: ci-Explicit-set-IPV6_AUTOCONF-and-IPV6_FORCE_ACCEPT_RA-.patch Patch9: ci-Add-config-modules-for-controlling-IBM-PowerVM-RMC.-.patch +# For bz#1881462 - [rhel8][cloud-init] ifup bond0.504 Error: Connection activation failed: No suitable device found for this connection +Patch10: ci-network-Fix-type-and-respect-name-when-rendering-vla.patch BuildArch: noarch @@ -214,6 +216,11 @@ fi %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %changelog +* Fri Nov 27 2020 Miroslav Rezanina - 20.3-5.el8 +- ci-network-Fix-type-and-respect-name-when-rendering-vla.patch [bz#1881462] +- Resolves: bz#1881462 + ([rhel8][cloud-init] ifup bond0.504 Error: Connection activation failed: No suitable device found for this connection) + * Tue Nov 24 2020 Miroslav Rezanina - 20.3-4.el8 - ci-Changing-permission-of-cloud-init-generator-to-755.patch [bz#1897528] - Resolves: bz#1897528