diff --git a/SOURCES/ci-cloudinit-net-handle-two-different-routes-for-the-sa.patch b/SOURCES/ci-cloudinit-net-handle-two-different-routes-for-the-sa.patch new file mode 100644 index 0000000..3eafc72 --- /dev/null +++ b/SOURCES/ci-cloudinit-net-handle-two-different-routes-for-the-sa.patch @@ -0,0 +1,87 @@ +From e0eca40388080dabf6598c0d9653ea50ae10c984 Mon Sep 17 00:00:00 2001 +From: Emanuele Giuseppe Esposito +Date: Tue, 7 Dec 2021 10:04:43 +0100 +Subject: [PATCH] cloudinit/net: handle two different routes for the same ip + (#1124) + +RH-Author: Emanuele Giuseppe Esposito +RH-MergeRequest: 15: cloudinit/net: handle two different routes for the same ip (#1124) +RH-Commit: [1/1] b623a76ccd642e22e8d9c4aebc26f0b0cec8118b (eesposit/cloud-init-centos-) +RH-Bugzilla: 2028031 +RH-Acked-by: Mohamed Gamal Morsy +RH-Acked-by: Eduardo Otubo + +commit 0e25076b34fa995161b83996e866c0974cee431f +Author: Emanuele Giuseppe Esposito +Date: Mon Dec 6 18:34:26 2021 +0100 + + cloudinit/net: handle two different routes for the same ip (#1124) + + If we set a dhcp server side like this: + $ cat /var/tmp/cloud-init/cloud-init-dhcp-f0rie5tm/dhcp.leases + lease { + ... + option classless-static-routes 31.169.254.169.254 0.0.0.0,31.169.254.169.254 + 10.112.143.127,22.10.112.140 0.0.0.0,0 10.112.140.1; + ... + } + cloud-init fails to configure the routes via 'ip route add' because to there are + two different routes for 169.254.169.254: + + $ ip -4 route add 192.168.1.1/32 via 0.0.0.0 dev eth0 + $ ip -4 route add 192.168.1.1/32 via 10.112.140.248 dev eth0 + + But NetworkManager can handle such scenario successfully as it uses "ip route append". + So change cloud-init to also use "ip route append" to fix the issue: + + $ ip -4 route append 192.168.1.1/32 via 0.0.0.0 dev eth0 + $ ip -4 route append 192.168.1.1/32 via 10.112.140.248 dev eth0 + + Signed-off-by: Emanuele Giuseppe Esposito + + RHBZ: #2003231 + +Conflicts: + cloudinit/net/tests/test_init.py: a mock call in + test_ephemeral_ipv4_network_with_rfc3442_static_routes is not + present downstream. + +Signed-off-by: Emanuele Giuseppe Esposito +--- + cloudinit/net/__init__.py | 2 +- + cloudinit/net/tests/test_init.py | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py +index de65e7af..4bdc1bda 100644 +--- a/cloudinit/net/__init__.py ++++ b/cloudinit/net/__init__.py +@@ -1076,7 +1076,7 @@ class EphemeralIPv4Network(object): + if gateway != "0.0.0.0/0": + via_arg = ['via', gateway] + subp.subp( +- ['ip', '-4', 'route', 'add', net_address] + via_arg + ++ ['ip', '-4', 'route', 'append', net_address] + via_arg + + ['dev', self.interface], capture=True) + self.cleanup_cmds.insert( + 0, ['ip', '-4', 'route', 'del', net_address] + via_arg + +diff --git a/cloudinit/net/tests/test_init.py b/cloudinit/net/tests/test_init.py +index 0535387a..6754df8d 100644 +--- a/cloudinit/net/tests/test_init.py ++++ b/cloudinit/net/tests/test_init.py +@@ -715,10 +715,10 @@ class TestEphemeralIPV4Network(CiTestCase): + ['ip', '-family', 'inet', 'link', 'set', 'dev', 'eth0', 'up'], + capture=True), + mock.call( +- ['ip', '-4', 'route', 'add', '169.254.169.254/32', ++ ['ip', '-4', 'route', 'append', '169.254.169.254/32', + 'via', '192.168.2.1', 'dev', 'eth0'], capture=True), + mock.call( +- ['ip', '-4', 'route', 'add', '0.0.0.0/0', ++ ['ip', '-4', 'route', 'append', '0.0.0.0/0', + 'via', '192.168.2.1', 'dev', 'eth0'], capture=True)] + expected_teardown_calls = [ + mock.call( +-- +2.27.0 + diff --git a/SOURCES/ci-fix-error-on-upgrade-caused-by-new-vendordata2-attri.patch b/SOURCES/ci-fix-error-on-upgrade-caused-by-new-vendordata2-attri.patch new file mode 100644 index 0000000..d1e65bc --- /dev/null +++ b/SOURCES/ci-fix-error-on-upgrade-caused-by-new-vendordata2-attri.patch @@ -0,0 +1,174 @@ +From 83f3d481c5f0d962bff5bacfd2c323529754869e Mon Sep 17 00:00:00 2001 +From: Amy Chen +Date: Thu, 2 Dec 2021 18:11:08 +0800 +Subject: [PATCH] fix error on upgrade caused by new vendordata2 attributes + +RH-Author: xiachen +RH-MergeRequest: 14: fix error on upgrade caused by new vendordata2 attributes +RH-Commit: [1/1] ef14db399cd1fe6e4ba847d98acee15fef8021de (xiachen/cloud-init-centos) +RH-Bugzilla: 2028381 +RH-Acked-by: Eduardo Otubo +RH-Acked-by: Mohamed Gamal Morsy +RH-Acked-by: Emanuele Giuseppe Esposito + +commit d132356cc361abef2d90d4073438f3ab759d5964 +Author: James Falcon +Date: Mon Apr 19 11:31:28 2021 -0500 + + fix error on upgrade caused by new vendordata2 attributes (#869) + + In #777, we added 'vendordata2' and 'vendordata2_raw' attributes to + the DataSource class, but didn't use the upgrade framework to deal + with an unpickle after upgrade. This commit adds the necessary + upgrade code. + + Additionally, added a smaller-scope upgrade test to our integration + tests that will be run on every CI run so we catch these issues + immediately in the future. + + LP: #1922739 + +Signed-off-by: Amy Chen +--- + cloudinit/sources/__init__.py | 12 +++++++++++- + cloudinit/tests/test_upgrade.py | 4 ++++ + tests/integration_tests/clouds.py | 4 ++-- + tests/integration_tests/test_upgrade.py | 25 ++++++++++++++++++++++++- + 4 files changed, 41 insertions(+), 4 deletions(-) + +diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py +index 1ad1880d..7d74f8d9 100644 +--- a/cloudinit/sources/__init__.py ++++ b/cloudinit/sources/__init__.py +@@ -24,6 +24,7 @@ from cloudinit import util + from cloudinit.atomic_helper import write_json + from cloudinit.event import EventType + from cloudinit.filters import launch_index ++from cloudinit.persistence import CloudInitPickleMixin + from cloudinit.reporting import events + + DSMODE_DISABLED = "disabled" +@@ -134,7 +135,7 @@ URLParams = namedtuple( + 'URLParms', ['max_wait_seconds', 'timeout_seconds', 'num_retries']) + + +-class DataSource(metaclass=abc.ABCMeta): ++class DataSource(CloudInitPickleMixin, metaclass=abc.ABCMeta): + + dsmode = DSMODE_NETWORK + default_locale = 'en_US.UTF-8' +@@ -196,6 +197,8 @@ class DataSource(metaclass=abc.ABCMeta): + # non-root users + sensitive_metadata_keys = ('merged_cfg', 'security-credentials',) + ++ _ci_pkl_version = 1 ++ + def __init__(self, sys_cfg, distro, paths, ud_proc=None): + self.sys_cfg = sys_cfg + self.distro = distro +@@ -218,6 +221,13 @@ class DataSource(metaclass=abc.ABCMeta): + else: + self.ud_proc = ud_proc + ++ def _unpickle(self, ci_pkl_version: int) -> None: ++ """Perform deserialization fixes for Paths.""" ++ if not hasattr(self, 'vendordata2'): ++ self.vendordata2 = None ++ if not hasattr(self, 'vendordata2_raw'): ++ self.vendordata2_raw = None ++ + def __str__(self): + return type_utils.obj_name(self) + +diff --git a/cloudinit/tests/test_upgrade.py b/cloudinit/tests/test_upgrade.py +index f79a2536..71cea616 100644 +--- a/cloudinit/tests/test_upgrade.py ++++ b/cloudinit/tests/test_upgrade.py +@@ -43,3 +43,7 @@ class TestUpgrade: + def test_blacklist_drivers_set_on_networking(self, previous_obj_pkl): + """We always expect Networking.blacklist_drivers to be initialised.""" + assert previous_obj_pkl.distro.networking.blacklist_drivers is None ++ ++ def test_vendordata_exists(self, previous_obj_pkl): ++ assert previous_obj_pkl.vendordata2 is None ++ assert previous_obj_pkl.vendordata2_raw is None +\ No newline at end of file +diff --git a/tests/integration_tests/clouds.py b/tests/integration_tests/clouds.py +index 9527a413..1d0b9d83 100644 +--- a/tests/integration_tests/clouds.py ++++ b/tests/integration_tests/clouds.py +@@ -100,14 +100,14 @@ class IntegrationCloud(ABC): + # Even if we're using the default key, it may still have a + # different name in the clouds, so we need to set it separately. + self.cloud_instance.key_pair.name = settings.KEYPAIR_NAME +- self._released_image_id = self._get_initial_image() ++ self.released_image_id = self._get_initial_image() + self.snapshot_id = None + + @property + def image_id(self): + if self.snapshot_id: + return self.snapshot_id +- return self._released_image_id ++ return self.released_image_id + + def emit_settings_to_log(self) -> None: + log.info( +diff --git a/tests/integration_tests/test_upgrade.py b/tests/integration_tests/test_upgrade.py +index c20cb3c1..48e0691b 100644 +--- a/tests/integration_tests/test_upgrade.py ++++ b/tests/integration_tests/test_upgrade.py +@@ -1,4 +1,5 @@ + import logging ++import os + import pytest + import time + from pathlib import Path +@@ -8,6 +9,8 @@ from tests.integration_tests.conftest import ( + get_validated_source, + session_start_time, + ) ++from tests.integration_tests.instances import CloudInitSource ++ + + log = logging.getLogger('integration_testing') + +@@ -63,7 +66,7 @@ def test_upgrade(session_cloud: IntegrationCloud): + return # type checking doesn't understand that skip raises + + launch_kwargs = { +- 'image_id': session_cloud._get_initial_image(), ++ 'image_id': session_cloud.released_image_id, + } + + image = ImageSpecification.from_os_image() +@@ -93,6 +96,26 @@ def test_upgrade(session_cloud: IntegrationCloud): + instance.install_new_cloud_init(source, take_snapshot=False) + instance.execute('hostname something-else') + _restart(instance) ++ assert instance.execute('cloud-init status --wait --long').ok + _output_to_compare(instance, after_path, netcfg_path) + + log.info('Wrote upgrade test logs to %s and %s', before_path, after_path) ++ ++ ++@pytest.mark.ci ++@pytest.mark.ubuntu ++def test_upgrade_package(session_cloud: IntegrationCloud): ++ if get_validated_source(session_cloud) != CloudInitSource.DEB_PACKAGE: ++ not_run_message = 'Test only supports upgrading to build deb' ++ if os.environ.get('TRAVIS'): ++ # If this isn't running on CI, we should know ++ pytest.fail(not_run_message) ++ else: ++ pytest.skip(not_run_message) ++ ++ launch_kwargs = {'image_id': session_cloud.released_image_id} ++ ++ with session_cloud.launch(launch_kwargs=launch_kwargs) as instance: ++ instance.install_deb() ++ instance.restart() ++ assert instance.execute('cloud-init status --wait --long').ok +-- +2.27.0 + diff --git a/SPECS/cloud-init.spec b/SPECS/cloud-init.spec index 01deac3..3193490 100644 --- a/SPECS/cloud-init.spec +++ b/SPECS/cloud-init.spec @@ -1,6 +1,6 @@ Name: cloud-init Version: 21.1 -Release: 12%{?dist} +Release: 14%{?dist} Summary: Cloud instance init scripts License: ASL 2.0 or GPLv3 URL: http://launchpad.net/cloud-init @@ -30,6 +30,10 @@ Patch11: ci-Inhibit-sshd-keygen-.service-if-cloud-init-is-active.patch Patch12: ci-cc_ssh.py-fix-private-key-group-owner-and-permission.patch # For bz#2016305 - disable-sshd-keygen-if-cloud-init-active.conf:8: Missing '=', ignoring line Patch13: ci-remove-unnecessary-EOF-string-in-disable-sshd-keygen.patch +# For bz#2028381 - cloud-init.service fails to start after package update +Patch14: ci-fix-error-on-upgrade-caused-by-new-vendordata2-attri.patch +# For bz#2028031 - [RHEL-9] Above 19.2 of cloud-init fails to configure routes when configuring static and default routes to the same destination IP +Patch15: ci-cloudinit-net-handle-two-different-routes-for-the-sa.patch # Source-git patches @@ -227,6 +231,16 @@ fi %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %changelog +* Tue Dec 14 2021 Miroslav Rezanina - 21.1-14 +- ci-cloudinit-net-handle-two-different-routes-for-the-sa.patch [bz#2028031] +- Resolves: bz#2028031 + ([RHEL-9] Above 19.2 of cloud-init fails to configure routes when configuring static and default routes to the same destination IP) + +* Mon Dec 06 2021 Miroslav Rezanina - 21.1-13 +- ci-fix-error-on-upgrade-caused-by-new-vendordata2-attri.patch [bz#2028381] +- Resolves: bz#2028381 + (cloud-init.service fails to start after package update) + * Mon Nov 01 2021 Miroslav Rezanina - 21.1-12 - ci-remove-unnecessary-EOF-string-in-disable-sshd-keygen.patch [bz#2016305] - Resolves: bz#2016305