Auto sync2gitlab import of cloud-init-22.1-8.el8.src.rpm

This commit is contained in:
CentOS Sources 2023-02-02 20:09:52 +00:00
parent f35d6c09c3
commit 703945281e
2 changed files with 92 additions and 1 deletions

View File

@ -0,0 +1,84 @@
From ddfd2eba79b4849309c37472dfb5852811b03391 Mon Sep 17 00:00:00 2001
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Date: Thu, 19 Jan 2023 09:46:10 +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: 88: cc_set_hostname: ignore /var/lib/cloud/data/set-hostname if it's empty (#1967)
RH-Bugzilla: 2162258
RH-Acked-by: Mohamed Gamal Morsy <mmorsy@redhat.com>
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
RH-Commit: [1/1] 04aaaf46290c4488dd46c9c2673b0bf038b7d311
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2162258
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.39.1

View File

@ -6,7 +6,7 @@
Name: cloud-init Name: cloud-init
Version: 22.1 Version: 22.1
Release: 7%{?dist} Release: 8%{?dist}
Summary: Cloud instance init scripts Summary: Cloud instance init scripts
Group: System Environment/Base Group: System Environment/Base
@ -49,6 +49,8 @@ Patch14: ci-Revert-Use-Network-Manager-and-Netplan-as-default-re.patch
Patch15: ci-cloud.cfg.tmpl-make-sure-centos-settings-are-identic.patch Patch15: ci-cloud.cfg.tmpl-make-sure-centos-settings-are-identic.patch
# For bz#2151861 - [RHEL-8] Ensure network ready before cloud-init service runs on RHEL # For bz#2151861 - [RHEL-8] Ensure network ready before cloud-init service runs on RHEL
Patch16: ci-Ensure-network-ready-before-cloud-init-service-runs-.patch Patch16: ci-Ensure-network-ready-before-cloud-init-service-runs-.patch
# For bz#2162258 - systemd[1]: Failed to start Initial cloud-init job after reboot system via sysrq 'b' [RHEL-8]
Patch17: ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch
BuildArch: noarch BuildArch: noarch
@ -234,6 +236,11 @@ fi
%config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf
%changelog %changelog
* Mon Jan 30 2023 Camilla Conte <cconte@redhat.com> - 22.1-8
- ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch [bz#2162258]
- Resolves: bz#2162258
(systemd[1]: Failed to start Initial cloud-init job after reboot system via sysrq 'b' [RHEL-8])
* Wed Dec 28 2022 Camilla Conte <cconte@redhat.com> - 22.1-7 * Wed Dec 28 2022 Camilla Conte <cconte@redhat.com> - 22.1-7
- ci-Ensure-network-ready-before-cloud-init-service-runs-.patch [bz#2151861] - ci-Ensure-network-ready-before-cloud-init-service-runs-.patch [bz#2151861]
- Resolves: bz#2151861 - Resolves: bz#2151861