From 8d1a20c4b45ae5350ae2c530a5e49cb77bc517ff Mon Sep 17 00:00:00 2001 From: Miroslav Rezanina Date: Thu, 14 Mar 2024 03:18:44 -0400 Subject: [PATCH] * Thu Mar 14 2024 Miroslav Rezanina - 23.4-7 - ci-Retain-exit-code-in-cloud-init-status-for-recoverabl.patch [RHEL-28817] - Resolves: RHEL-28817 ([RHEL 8.10] cloud-init 23.4 returns 2 on recoverable errors instead of 0) --- ...-in-cloud-init-status-for-recoverabl.patch | 65 +++++++++++++++++++ cloud-init.spec | 9 ++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 ci-Retain-exit-code-in-cloud-init-status-for-recoverabl.patch diff --git a/ci-Retain-exit-code-in-cloud-init-status-for-recoverabl.patch b/ci-Retain-exit-code-in-cloud-init-status-for-recoverabl.patch new file mode 100644 index 0000000..fc28030 --- /dev/null +++ b/ci-Retain-exit-code-in-cloud-init-status-for-recoverabl.patch @@ -0,0 +1,65 @@ +From 9da40a7e46e40eb090538f9d8a5aa6049fbbc5b8 Mon Sep 17 00:00:00 2001 +From: Ani Sinha +Date: Tue, 12 Mar 2024 12:52:10 +0530 +Subject: [PATCH] Retain exit code in cloud-init status for recoverable errors + +RH-Author: Ani Sinha +RH-MergeRequest: 126: Retain exit code in cloud-init status for recoverable errors +RH-Jira: RHEL-28817 +RH-Acked-by: Emanuele Giuseppe Esposito +RH-Acked-by: Cathy Avery +RH-Commit: [1/1] 8c45ffe77ed8e964c35af4705d65daaf8282038f + +Version 23.4 of cloud-init changed the status code reported by cloud-init for +recoverable errors from 0 to 2. Please see the commit +70acb7f2a30d58 ("Add support for cloud-init "degraded" state (#4500)") + +This change has the potential to break customers who are expecting a 0 status +and where warnings can be expected. Hence, revert the status code from 2 to 0 +even in case of recoverable errors. This retains the old behavior and hence +avoids breaking scripts and software stack that expects 0 on the end user side. + +Cannonical has made a similar change downstream for similar reasons. Please see +https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/2048522 +and the corresponding downstream patch: +https://github.com/canonical/cloud-init/pull/4747/commits/adce34bfd214e4eecdf87329486f30f0898dd303 + +This patch has limited risk as it narrowly only restores the old status +code for recoverable errors and does not modify anything else. + +X-downstream-only: true +Signed-off-by: Ani Sinha +--- + cloudinit/cmd/status.py | 2 +- + tests/unittests/cmd/test_status.py | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cloudinit/cmd/status.py b/cloudinit/cmd/status.py +index f5ee9c11..849c80bc 100644 +--- a/cloudinit/cmd/status.py ++++ b/cloudinit/cmd/status.py +@@ -225,7 +225,7 @@ def handle_status_args(name, args) -> int: + return 1 + # Recoverable error + elif details.status in UXAppStatusDegradedMap.values(): +- return 2 ++ return 0 + return 0 + + +diff --git a/tests/unittests/cmd/test_status.py b/tests/unittests/cmd/test_status.py +index 6c85a59a..567b517a 100644 +--- a/tests/unittests/cmd/test_status.py ++++ b/tests/unittests/cmd/test_status.py +@@ -636,7 +636,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin + }, + None, + MyArgs(long=False, wait=False, format="json"), +- 2, ++ 0, + { + "boot_status_code": "enabled-by-kernel-cmdline", + "datasource": "nocloud", +-- +2.39.3 + diff --git a/cloud-init.spec b/cloud-init.spec index d3a6312..2abbc1c 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -6,7 +6,7 @@ Name: cloud-init Version: 23.4 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Cloud instance init scripts Group: System Environment/Base @@ -37,6 +37,8 @@ Patch20: ci-ci-Pin-pytest-8.0.0.-4816.patch Patch21: ci-fix-Add-types-to-network-v1-schema-4841.patch # For RHEL-21290 - Unknown lvalue 'ConditionEnvironment' in section 'Unit' for /usr/lib/systemd/system/cloud-init.target,cloud-init.service Patch22: ci-Revert-systemd-Standardize-cloud-init-systemd-enable.patch +# For RHEL-28817 - [RHEL 8.10] cloud-init 23.4 returns 2 on recoverable errors instead of 0 +Patch23: ci-Retain-exit-code-in-cloud-init-status-for-recoverabl.patch BuildArch: noarch @@ -252,6 +254,11 @@ fi %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %changelog +* Thu Mar 14 2024 Miroslav Rezanina - 23.4-7 +- ci-Retain-exit-code-in-cloud-init-status-for-recoverabl.patch [RHEL-28817] +- Resolves: RHEL-28817 + ([RHEL 8.10] cloud-init 23.4 returns 2 on recoverable errors instead of 0) + * Mon Mar 11 2024 Miroslav Rezanina - 23.4-6 - ci-Revert-systemd-Standardize-cloud-init-systemd-enable.patch [RHEL-21290] - Resolves: RHEL-21290