backport upstream patches
(cherry picked from commit 5044bad5379cdcd016715e0b9f48781465c8ce31)
This commit is contained in:
parent
5979562c69
commit
d6e192cf20
@ -0,0 +1,59 @@
|
||||
From eb1965a434360b3198768302f4196488d7c2511f Mon Sep 17 00:00:00 2001
|
||||
From: Bryan Fraschetti <bryan.fraschetti@canonical.com>
|
||||
Date: Mon, 3 Feb 2025 16:13:19 -0500
|
||||
Subject: [PATCH] Fix: GCE _get_data crashes if DHCP lease fails (#5998)
|
||||
|
||||
This commit addresses issue #5997 which reported crashes in init-local
|
||||
when cloud-init was examining GCELocal as a potential datasource. When
|
||||
all NICs failed at DHCP discovery cloud-init attempts to log the events
|
||||
by dereferencing a value that was never assigned.
|
||||
|
||||
This commit modifies the _get_data function of DataSourceGCE.py by
|
||||
adding an empty dictionary definition for the ret variable at the
|
||||
top level of the function and some debugging logs when a candidate NIC
|
||||
fails to obtain a DHCP lease. At the same time, the commit replaces the
|
||||
direct key access operator on ret with the safe lookup method get(). This
|
||||
commit also adds a unit test that mocks the observed situation.
|
||||
|
||||
Reference:https://github.com/canonical/cloud-init/commit/eb1965a434360b3198768302f4196488d7c2511f
|
||||
Conflict:not change test_gce.py (M_PATH and net.find_candidate_nics doesn't exist)
|
||||
|
||||
Fixes GH-5997
|
||||
---
|
||||
cloudinit/sources/DataSourceGCE.py | 13 +++++++------
|
||||
1 file changed, 7 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
|
||||
index 9f838bd..53b686f 100644
|
||||
--- a/cloudinit/sources/DataSourceGCE.py
|
||||
+++ b/cloudinit/sources/DataSourceGCE.py
|
||||
@@ -73,19 +73,20 @@ class DataSourceGCE(sources.DataSource):
|
||||
|
||||
def _get_data(self):
|
||||
url_params = self.get_url_params()
|
||||
+ ret = {}
|
||||
ret = util.log_time(
|
||||
LOG.debug, 'Crawl of GCE metadata service',
|
||||
read_md, kwargs={'address': self.metadata_address,
|
||||
'url_params': url_params})
|
||||
|
||||
- if not ret['success']:
|
||||
- if ret['platform_reports_gce']:
|
||||
- LOG.warning(ret['reason'])
|
||||
+ if not ret.get("success"):
|
||||
+ if ret.get("platform_reports_gce"):
|
||||
+ LOG.warning(ret.get("reason"))
|
||||
else:
|
||||
- LOG.debug(ret['reason'])
|
||||
+ LOG.debug(ret.get("reason"))
|
||||
return False
|
||||
- self.metadata = ret['meta-data']
|
||||
- self.userdata_raw = ret['user-data']
|
||||
+ self.metadata = ret.get("meta-data")
|
||||
+ self.userdata_raw = ret.get("user-data")
|
||||
return True
|
||||
|
||||
@property
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
From b45d66a03659f8e4780b6b55e51edcbd2f6f012d Mon Sep 17 00:00:00 2001
|
||||
From: MKhatibzadeh <32599707+masihkhatibzadeh99@users.noreply.github.com>
|
||||
Date: Fri, 7 Feb 2025 18:13:43 +0330
|
||||
Subject: [PATCH] fix: Ensure fqdn is treated as string in get_hostname_fqdn
|
||||
(#5993)
|
||||
|
||||
Explicitly cast fqdn to a string before processing.
|
||||
|
||||
Reference:https://github.com/canonical/cloud-init/commit/b45d66a03659f8e4780b6b55e51edcbd2f6f012d
|
||||
Conflict:(1)delete ", _" for util.get_hostname_fqdn() result in new test, refer to commit 74e4349
|
||||
(2)not change .github-cla-signers
|
||||
(3)change cloudinit/tests/test_util.py not tests/unittests/test_util.py
|
||||
|
||||
Fixes GH-5989
|
||||
|
||||
Co-authored-by: masih.khatibzdeh <masih.khatibzadeh@snapp.cab>
|
||||
---
|
||||
cloudinit/util.py | 2 +-
|
||||
cloudinit/tests/test_util.py | 16 ++++++++++++++++
|
||||
2 files changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/cloudinit/util.py b/cloudinit/util.py
|
||||
index e380848..70e0b76 100644
|
||||
--- a/cloudinit/util.py
|
||||
+++ b/cloudinit/util.py
|
||||
@@ -1027,7 +1027,7 @@ def get_hostname_fqdn(cfg, cloud, metadata_only=False):
|
||||
"""
|
||||
if "fqdn" in cfg:
|
||||
# user specified a fqdn. Default hostname then is based off that
|
||||
- fqdn = cfg['fqdn']
|
||||
+ fqdn = str(cfg["fqdn"])
|
||||
hostname = get_cfg_option_str(cfg, "hostname", fqdn.split('.')[0])
|
||||
else:
|
||||
if "hostname" in cfg and cfg['hostname'].find('.') > 0:
|
||||
diff --git a/cloudinit/tests/test_util.py b/cloudinit/tests/test_util.py
|
||||
index 5fb2508..a51de4d 100644
|
||||
--- a/cloudinit/tests/test_util.py
|
||||
+++ b/cloudinit/tests/test_util.py
|
||||
@@ -448,6 +448,22 @@ class TestGetHostnameFqdn(CiTestCase):
|
||||
[{'fqdn': True, 'metadata_only': False},
|
||||
{'metadata_only': False}], mycloud.calls)
|
||||
|
||||
+ def test_get_hostname_fqdn_from_numeric_fqdn(self):
|
||||
+ """When cfg fqdn is numeric, ensure it is treated as a string."""
|
||||
+ hostname, fqdn = util.get_hostname_fqdn(
|
||||
+ cfg={"fqdn": 12345}, cloud=None
|
||||
+ )
|
||||
+ self.assertEqual("12345", hostname)
|
||||
+ self.assertEqual("12345", fqdn)
|
||||
+
|
||||
+ def test_get_hostname_fqdn_from_numeric_fqdn_with_domain(self):
|
||||
+ """When cfg fqdn is numeric with a domain, ensure correct parsing."""
|
||||
+ hostname, fqdn = util.get_hostname_fqdn(
|
||||
+ cfg={"fqdn": "12345.example.com"}, cloud=None
|
||||
+ )
|
||||
+ self.assertEqual("12345", hostname)
|
||||
+ self.assertEqual("12345.example.com", fqdn)
|
||||
+
|
||||
def test_get_hostname_fqdn_from_passes_metadata_only_to_cloud(self):
|
||||
"""Calls to cloud.get_hostname pass the metadata_only parameter."""
|
||||
mycloud = FakeCloud('cloudhost', 'cloudhost.mycloud.com')
|
||||
--
|
||||
2.33.0
|
||||
|
||||
57
backport-fix-Wait-for-udev-on-openstack-5947.patch
Normal file
57
backport-fix-Wait-for-udev-on-openstack-5947.patch
Normal file
@ -0,0 +1,57 @@
|
||||
From 7f09102ad601cb5225fa0ffe280d77a75f435e93 Mon Sep 17 00:00:00 2001
|
||||
From: Robert Schweikert <rjschwei@suse.com>
|
||||
Date: Tue, 7 Jan 2025 15:59:26 -0500
|
||||
Subject: [PATCH] fix: Wait for udev on openstack (#5947)
|
||||
|
||||
It is possible that we outrun udev and when we try to enumerate the macs
|
||||
any given mac may not yet be present. If we detect the condition give
|
||||
udev a chance to catch up and check the system macs again before
|
||||
triggering an error.
|
||||
|
||||
Reference:https://github.com/canonical/cloud-init/commit/7f09102ad601cb5225fa0ffe280d77a75f435e93
|
||||
Conflict:test format diff.
|
||||
|
||||
Fixes GH-4125
|
||||
---
|
||||
cloudinit/sources/helpers/openstack.py | 6 +++++-
|
||||
tests/unittests/test_datasource/test_configdrive.py | 7 +++++--
|
||||
2 files changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
|
||||
index 51e491f..2adbf5f 100644
|
||||
--- a/cloudinit/sources/helpers/openstack.py
|
||||
+++ b/cloudinit/sources/helpers/openstack.py
|
||||
@@ -702,7 +702,11 @@ def convert_net_json(network_json=None, known_macs=None):
|
||||
if not mac:
|
||||
raise ValueError("No mac_address or name entry for %s" % d)
|
||||
if mac not in known_macs:
|
||||
- raise ValueError("Unable to find a system nic for %s" % d)
|
||||
+ # Let's give udev a chance to catch up
|
||||
+ util.udevadm_settle()
|
||||
+ known_macs = net.get_interfaces_by_mac()
|
||||
+ if mac not in known_macs:
|
||||
+ raise ValueError("Unable to find a system nic for %s" % d)
|
||||
d['name'] = known_macs[mac]
|
||||
|
||||
for cfg, key, fmt, targets in link_updates:
|
||||
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
|
||||
index 5109723..f6ef537 100644
|
||||
--- a/tests/unittests/test_datasource/test_configdrive.py
|
||||
+++ b/tests/unittests/test_datasource/test_configdrive.py
|
||||
@@ -694,8 +694,11 @@ class TestConvertNetworkData(CiTestCase):
|
||||
|
||||
def test_convert_raises_value_error_on_missing_name(self):
|
||||
macs = {'aa:aa:aa:aa:aa:00': 'ens1'}
|
||||
- self.assertRaises(ValueError, openstack.convert_net_json,
|
||||
- NETWORK_DATA, known_macs=macs)
|
||||
+ with mock.patch(
|
||||
+ "cloudinit.sources.helpers.openstack.util.udevadm_settle"
|
||||
+ ):
|
||||
+ self.assertRaises(ValueError, openstack.convert_net_json,
|
||||
+ NETWORK_DATA, known_macs=macs)
|
||||
|
||||
def test_conversion_with_route(self):
|
||||
ncfg = openstack.convert_net_json(NETWORK_DATA_2,
|
||||
--
|
||||
2.33.0
|
||||
|
||||
57
backport-fix-correct-the-path-for-Chef-s-cache-5994.patch
Normal file
57
backport-fix-correct-the-path-for-Chef-s-cache-5994.patch
Normal file
@ -0,0 +1,57 @@
|
||||
From a0ebb8d35e41bae075a0762b7002bc4e6a2b6269 Mon Sep 17 00:00:00 2001
|
||||
From: MostafaTarek124eru
|
||||
<48182100+MostafaTarek124eru@users.noreply.github.com>
|
||||
Date: Mon, 3 Feb 2025 22:03:51 +0200
|
||||
Subject: [PATCH] fix: correct the path for Chef's cache (#5994)
|
||||
|
||||
Corrected the path for chef cache in cc_chef, schema-cloud-config-v1,
|
||||
and test_cc_chef.
|
||||
|
||||
Reference:https://github.com/canonical/cloud-init/commit/a0ebb8d35e41bae075a0762b7002bc4e6a2b6269
|
||||
Conflict:(1)not change schema-cloud-config-v1.json and .github-cla-signers
|
||||
(2)change test_handler_chef.py not test_cc_chef.py for test
|
||||
|
||||
Fixes GH-5090
|
||||
---
|
||||
cloudinit/config/cc_chef.py | 4 ++--
|
||||
tests/unittests/test_handler/test_handler_chef.py | 2 +-
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py
|
||||
index cb9fe12..21c87e9 100644
|
||||
--- a/cloudinit/config/cc_chef.py
|
||||
+++ b/cloudinit/config/cc_chef.py
|
||||
@@ -29,7 +29,7 @@ CHEF_DIRS = tuple([
|
||||
'/etc/chef',
|
||||
'/var/log/chef',
|
||||
'/var/lib/chef',
|
||||
- '/var/cache/chef',
|
||||
+ '/var/chef/cache',
|
||||
'/var/backups/chef',
|
||||
'/var/run/chef',
|
||||
])
|
||||
@@ -55,7 +55,7 @@ CHEF_RB_TPL_DEFAULTS = {
|
||||
'validation_cert': None,
|
||||
'client_key': '/etc/chef/client.pem',
|
||||
'json_attribs': CHEF_FB_PATH,
|
||||
- 'file_cache_path': '/var/cache/chef',
|
||||
+ 'file_cache_path': '/var/chef/cache',
|
||||
'file_backup_path': '/var/backups/chef',
|
||||
'pid_file': '/var/run/chef/client.pid',
|
||||
'show_time': True,
|
||||
diff --git a/tests/unittests/test_handler/test_handler_chef.py b/tests/unittests/test_handler/test_handler_chef.py
|
||||
index 0672ceb..b1d7ff9 100644
|
||||
--- a/tests/unittests/test_handler/test_handler_chef.py
|
||||
+++ b/tests/unittests/test_handler/test_handler_chef.py
|
||||
@@ -132,7 +132,7 @@ class TestChef(FilesystemMockingTestCase):
|
||||
environment "_default"
|
||||
node_name "iid-datasource-none"
|
||||
json_attribs "/etc/chef/firstboot.json"
|
||||
- file_cache_path "/var/cache/chef"
|
||||
+ file_cache_path "/var/chef/cache"
|
||||
file_backup_path "/var/backups/chef"
|
||||
pid_file "/var/run/chef/client.pid"
|
||||
Chef::Log::Formatter.show_time = true
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: cloud-init
|
||||
Version: 21.4
|
||||
Release: 32
|
||||
Release: 33
|
||||
Summary: the defacto multi-distribution package that handles early initialization of a cloud instance.
|
||||
License: ASL 2.0 or GPLv3
|
||||
URL: http://launchpad.net/cloud-init
|
||||
@ -87,6 +87,10 @@ Patch6052: backport-fix-properly-handle-blank-lines-in-fstab-5643.patch
|
||||
Patch6053: backport-chore-set-recursive-False-for-ensure_dir-if-parent-p.patch
|
||||
Patch6054: backport-test-openstack-Test-bond-mac-address.patch
|
||||
Patch6055: backport-fix-Ensure-properties-for-bonded-interfaces-are-prop.patch
|
||||
Patch6056: backport-fix-Wait-for-udev-on-openstack-5947.patch
|
||||
Patch6057: backport-fix-correct-the-path-for-Chef-s-cache-5994.patch
|
||||
Patch6058: backport-Fix-GCE-_get_data-crashes-if-DHCP-lease-fails-5998.patch
|
||||
Patch6059: backport-fix-Ensure-fqdn-is-treated-as-string-in-get_hostname.patch
|
||||
|
||||
BuildRequires: pkgconfig(systemd) python3-devel python3-setuptools systemd
|
||||
BuildRequires: iproute python3-configobj python3-httpretty >= 0.8.14-2
|
||||
@ -132,7 +136,31 @@ rm -f $RPM_BUILD_DIR/%{name}-%{version}/tests/unittests/test_handler/test_handle
|
||||
rm -f $RPM_BUILD_DIR/%{name}-%{version}/tests/unittests/test_datasource/test_opennebula.py
|
||||
rm -f $RPM_BUILD_DIR/%{name}-%{version}/tests/unittests/test_net_freebsd.py
|
||||
|
||||
python3 -m pytest tests/unittests/
|
||||
SKIP_TESTS=""
|
||||
|
||||
# 检测是否存在多个网卡的MAC地址是ee:ee:ee:ee:ee:ee
|
||||
# https://docs.tigera.io/calico/latest/reference/faq#why-do-all-cali-interfaces-have-the-mac-address-eeeeeeeeeeee
|
||||
MAC_ADDR="ee:ee:ee:ee:ee:ee"
|
||||
interfaces=$(ls /sys/class/net)
|
||||
duplicate_mac_matched_count=0
|
||||
for iface in $interfaces; do
|
||||
if [ -e "/sys/class/net/$iface/address" ]; then
|
||||
iface_mac=$(cat /sys/class/net/$iface/address)
|
||||
if [ "$iface_mac" == "$MAC_ADDR" ]; then
|
||||
duplicate_mac_matched_count=$((duplicate_mac_matched_count+1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$duplicate_mac_matched_count" -gt 1 ]; then
|
||||
SKIP_TESTS="not test_dhcp.py and not test_network_state.py and not test_configdrive.py"
|
||||
fi
|
||||
|
||||
if [ -n "$SKIP_TESTS" ]; then
|
||||
python3 -m pytest tests/unittests/ -k "$SKIP_TESTS"
|
||||
else
|
||||
python3 -m pytest tests/unittests/
|
||||
fi
|
||||
|
||||
%pre
|
||||
|
||||
@ -197,6 +225,13 @@ fi
|
||||
%exclude /usr/share/doc/*
|
||||
|
||||
%changelog
|
||||
* Wed Mar 05 2025 Linux_zhang <zhangruifang@h-partners.com> - 21.4-33
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:backport upstream patches
|
||||
skip some test if there are multiple NICs with the MAC address 'ee:ee:ee:ee:ee:ee'
|
||||
|
||||
* Fri Dec 06 2024 shixuantong <shixuantong1@huawei.com> - 21.4-32
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user