Merge branch 'c8' into a8

This commit is contained in:
eabdullin 2023-02-21 09:41:15 +00:00 committed by Stepan Oksanichenko
commit 22c0ba2138
3 changed files with 142 additions and 2 deletions

View File

@ -0,0 +1,43 @@
From 5bed421bffa0f1937c366e17ea8babaacf801536 Mon Sep 17 00:00:00 2001
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Date: Wed, 14 Dec 2022 09:16:15 +0100
Subject: [PATCH] Ensure network ready before cloud-init service runs on RHEL
(#1893)
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
RH-MergeRequest: 86: Ensure network ready before cloud-init service runs on RHEL (#1893)
RH-Bugzilla: 2153182
RH-Acked-by: Mohamed Gamal Morsy <mmorsy@redhat.com>
RH-Acked-by: Camilla Conte <cconte@redhat.com>
RH-Commit: [1/1] 7eff85c95da26f4083ddb217b1ac76bbac661f26
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2153182
commit 6e725f36647407d201af0603d7db11fc96a93d4d
Author: James Falcon <james.falcon@canonical.com>
Date: Tue Dec 13 10:55:23 2022 -0600
Ensure network ready before cloud-init service runs on RHEL (#1893)
LP: #1998655
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
systemd/cloud-init.service.tmpl | 1 +
1 file changed, 1 insertion(+)
diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl
index c170aef7..fc984d5c 100644
--- a/systemd/cloud-init.service.tmpl
+++ b/systemd/cloud-init.service.tmpl
@@ -16,6 +16,7 @@ After=networking.service
"miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %}
After=network.service
After=NetworkManager.service
+After=NetworkManager-wait-online.service
{% endif %}
{% if variant in ["suse"] %}
After=wicked.service
--
2.38.1

View File

@ -0,0 +1,84 @@
From 836be9931cad907dc71fc9e769d185e09a33e120 Mon Sep 17 00:00:00 2001
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Date: Tue, 31 Jan 2023 17:14:42 +0100
Subject: [PATCH] cc_set_hostname: ignore /var/lib/cloud/data/set-hostname if
it's empty (#1967)
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
RH-MergeRequest: 90: cc_set_hostname: ignore /var/lib/cloud/data/set-hostname if it's empty (#1967)
RH-Bugzilla: 2165945
RH-Acked-by: Mohamed Gamal Morsy <mmorsy@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Commit: [1/1] 2efa7c1ac15932be38bd86b9b76f8f3b18038de6
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2165945
commit 9c7502a801763520639c66125eb373123d1e4f44
Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Date: Wed Jan 18 17:55:16 2023 +0100
cc_set_hostname: ignore /var/lib/cloud/data/set-hostname if it's empty (#1967)
If the file exists but is empty, do nothing.
Otherwise cloud-init will crash because it does not handle the empty file.
RHBZ: 2140893
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
cloudinit/config/cc_set_hostname.py | 2 +-
tests/unittests/config/test_cc_set_hostname.py | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/cloudinit/config/cc_set_hostname.py b/cloudinit/config/cc_set_hostname.py
index eb0ca328..9d78f6ad 100644
--- a/cloudinit/config/cc_set_hostname.py
+++ b/cloudinit/config/cc_set_hostname.py
@@ -86,7 +86,7 @@ def handle(name, cfg, cloud, log, _args):
# distro._read_hostname implementation so we only validate one artifact.
prev_fn = os.path.join(cloud.get_cpath("data"), "set-hostname")
prev_hostname = {}
- if os.path.exists(prev_fn):
+ if os.path.exists(prev_fn) and os.stat(prev_fn).st_size > 0:
prev_hostname = util.load_json(util.load_file(prev_fn))
hostname_changed = hostname != prev_hostname.get(
"hostname"
diff --git a/tests/unittests/config/test_cc_set_hostname.py b/tests/unittests/config/test_cc_set_hostname.py
index fd994c4e..a819039b 100644
--- a/tests/unittests/config/test_cc_set_hostname.py
+++ b/tests/unittests/config/test_cc_set_hostname.py
@@ -5,6 +5,7 @@ import os
import shutil
import tempfile
from io import BytesIO
+from pathlib import Path
from unittest import mock
from configobj import ConfigObj
@@ -204,5 +205,21 @@ class TestHostname(t_help.FilesystemMockingTestCase):
str(ctx_mgr.exception),
)
+ def test_ignore_empty_previous_artifact_file(self):
+ cfg = {
+ "hostname": "blah",
+ "fqdn": "blah.blah.blah.yahoo.com",
+ }
+ distro = self._fetch_distro("debian")
+ paths = helpers.Paths({"cloud_dir": self.tmp})
+ ds = None
+ cc = cloud.Cloud(ds, paths, {}, distro, None)
+ self.patchUtils(self.tmp)
+ prev_fn = Path(cc.get_cpath("data")) / "set-hostname"
+ prev_fn.touch()
+ cc_set_hostname.handle("cc_set_hostname", cfg, cc, LOG, [])
+ contents = util.load_file("/etc/hostname")
+ self.assertEqual("blah", contents.strip())
+
# vi: ts=4 expandtab
--
2.37.3

View File

@ -6,7 +6,7 @@
Name: cloud-init
Version: 22.1
Release: 5%{?dist}.alma
Release: 6%{?dist}.2.alma
Summary: Cloud instance init scripts
Group: System Environment/Base
@ -45,6 +45,10 @@ Patch13: ci-Revert-Add-native-NetworkManager-support-1224.patch
# For bz#2104393 - [RHEL-8.7]Failed to config static IP and IPv6 according to VMware Customization Config File
# For bz#2098624 - [RHEL-8.7] IPv6 not workable when cloud-init configure network using NM keyfiles
Patch14: ci-Revert-Use-Network-Manager-and-Netplan-as-default-re.patch
# For bz#2153182 - [RHEL-8] Ensure network ready before cloud-init service runs on RHEL [rhel-8.7.0.z]
Patch15: ci-Ensure-network-ready-before-cloud-init-service-runs-.patch
# For bz#2165945 - systemd[1]: Failed to start Initial cloud-init job after reboot system via sysrq 'b' [RHEL-8] [rhel-8.7.0.z]
Patch16: ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch
# AlmaLinux patches
Patch100: cloud-init-20.3-add_almalinux.patch
@ -233,9 +237,18 @@ fi
%config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf
%changelog
* Tue Nov 08 2022 Andrew Lukoshko <alukoshko@almalinux.org> - 22.1-5.alma
* Tue Feb 21 2023 Andrew Lukoshko <alukoshko@almalinux.org> - 22.1-6.el8_7.2.alma
- AlmaLinux support
* Tue Feb 14 2023 Jon Maloy <jmaloy@redhat.com> - 22.1-6.el8_7.2
- ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch [bz#2165945]
- Resolves: bz#2165945
(systemd[1]: Failed to start Initial cloud-init job after reboot system via sysrq 'b' [RHEL-8] [rhel-8.7.0.z])
* Wed Dec 28 2022 Camilla Conte <cconte@redhat.com> - 22.1-6.el8_7
- ci-Ensure-network-ready-before-cloud-init-service-runs-.patch [bz#2153182]
- Resolves: bz#2153182
([RHEL-8] Ensure network ready before cloud-init service runs on RHEL [rhel-8.7.0.z])
* Wed Aug 17 2022 Jon Maloy <jmaloy@redhat.com> - 22.1-5
- ci-Revert-Add-native-NetworkManager-support-1224.patch [bz#2107464 bz#2110066 bz#2117526 bz#2104393 bz#2098624]
- ci-Revert-Use-Network-Manager-and-Netplan-as-default-re.patch [bz#2107464 bz#2110066 bz#2117526 bz#2104393 bz#2098624]