]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Populate Handle-new-cloud-init-error-code.patch Handle-new-cloud-init-error-code.patch
authorJohn Wolfe <john.wolfe@broadcom.com>
Tue, 30 Sep 2025 04:30:18 +0000 (21:30 -0700)
committerJohn Wolfe <john.wolfe@broadcom.com>
Tue, 30 Sep 2025 04:30:18 +0000 (21:30 -0700)
0001-Handle-new-cloud-init-error-code.patch [new file with mode: 0644]
README.md [new file with mode: 0644]

diff --git a/0001-Handle-new-cloud-init-error-code.patch b/0001-Handle-new-cloud-init-error-code.patch
new file mode 100644 (file)
index 0000000..8272b52
--- /dev/null
@@ -0,0 +1,68 @@
+From b826db9f862778abd9129f4b9073ac48d789cc15 Mon Sep 17 00:00:00 2001
+From: Pengpeng Sun <pengpeng.sun@broadcom.com>
+Date: Wed, 27 Aug 2025 14:19:58 +0800
+Subject: [PATCH] Handle new cloud-init error code and status
+
+The cloud-init v23.4 introduced a new exit code 2 that means cloud-init
+was able to complete gracefully, however something went wrong and should
+be investigated - a recoverable error.
+
+The existing Guest OS Customization in open-vm-tools treated a non "0" 
+exit code as a failure.
+
+This change follows the backwards-compatible suggestion in
+https://cloudinit.readthedocs.io/en/latest/explanation/return_codes.html
+to check that the return code is not equal to 1.  The deployPackage
+plugin will wait for cloud-init execution as long as it's status is
+"running" before triggering a reboot.
+
+Addresses open-vm-tools issue https://github.com/vmware/open-vm-tools/issues/768
+
+The file being updated should be consider to have the copyright
+updated to:
+
+ * Copyright (c) XXXX-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
+
+The 2025 Broadcom copyright information update is not part of this
+patch set to allow the patch to be easily applied to previous
+open-vm-tools source releases.
+---
+ open-vm-tools/libDeployPkg/linuxDeployment.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/open-vm-tools/libDeployPkg/linuxDeployment.c b/open-vm-tools/libDeployPkg/linuxDeployment.c
+index 5e9ccfbd155..eed0bcce095 100644
+--- a/open-vm-tools/libDeployPkg/linuxDeployment.c
++++ b/open-vm-tools/libDeployPkg/linuxDeployment.c
+@@ -1302,6 +1302,7 @@ static CLOUDINIT_STATUS_CODE
+ GetCloudinitStatus() {
+    // Cloud-init execution status messages
+    static const char* NOT_RUN = "not run";
++   static const char* NOT_STARTED = "not started";
+    static const char* RUNNING = "running";
+    static const char* DONE = "done";
+    static const char* ERROR = "error";
+@@ -1315,13 +1316,16 @@ GetCloudinitStatus() {
+                                            false,
+                                            cloudinitStatusCmdOutput,
+                                            MAX_LENGTH_CLOUDINIT_STATUS);
+-   if (forkExecResult != 0) {
+-      sLog(log_info, "Unable to get cloud-init status.");
+-      return CLOUDINIT_STATUS_UNKNOWN;
++   if (forkExecResult == 1) {
++      sLog(log_info, "Cloud-init experienced unrecoverable error.");
++      return CLOUDINIT_STATUS_ERROR;
+    } else {
+       if (strstr(cloudinitStatusCmdOutput, NOT_RUN) != NULL) {
+          sLog(log_info, "Cloud-init status is '%s'.", NOT_RUN);
+          return CLOUDINIT_STATUS_NOT_RUN;
++      } else if (strstr(cloudinitStatusCmdOutput, NOT_STARTED) != NULL) {
++         sLog(log_info, "Cloud-init status is '%s'.", NOT_STARTED);
++         return CLOUDINIT_STATUS_NOT_RUN;
+       } else if (strstr(cloudinitStatusCmdOutput, RUNNING) != NULL) {
+          sLog(log_info, "Cloud-init status is '%s'.", RUNNING);
+          return CLOUDINIT_STATUS_RUNNING;
+-- 
+2.47.3
+
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..dfb8dc4
--- /dev/null
+++ b/README.md
@@ -0,0 +1,35 @@
+#     Handle-new-cloud-init-error-code
+
+Reported in [OVT issue #768](https://github.com/vmware/open-vm-tools/issues/768), the current Guest OS Customization treated the new cloud-init exit code introduced in cloud-init v23.4 as a failure.
+
+```
+   0 - success
+   1 - unrecoverable error
+   2 - recoverable error
+```
+
+This patch to "libDeployPkg/linuxDeployment.c" will accept an exit code of 2 as a recoverable error.  The DeployPackage plugin will wait for cloud-init execution as long as it's status is "running" before triggering a reboot.
+
+This fix is targeted for the next minor release of open-vm-tools.
+
+The following patch provided to the open-vm-tools community can be used to apply the this fix to previous open-vm-tools releases.
+
+
+## For releases 12.1.5 through 13.0.5
+
+
+*   **[0001-Handle-new-cloud-init-error-code.patch](https://github.com/vmware/open-vm-tools/blob/Handle-new-cloud-init-error-code.patch/0001-Handle-new-cloud-init-error-code.patch)**
+
+
+## For releases 12.1.0 and earlier
+
+
+*   Please open an issue at https://github.com/vmware/open-vm-tools/issues and indicate the specific open-vm-tools release needed.
+
+
+The patch has been tested against the above open-vm-tools releases.  It applies cleanly with: 
+
+    git am        for a git repository.
+    patch -p2     in the top directory of an open-vm-tools source tree. 
+