]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Handle the new cloud-init error code and status
authorKruti Pendharkar <kp025370@broadcom.com>
Thu, 22 Jan 2026 04:42:54 +0000 (20:42 -0800)
committerKruti Pendharkar <kp025370@broadcom.com>
Thu, 22 Jan 2026 04:42:54 +0000 (20:42 -0800)
- A new error code[1] was introduced in cloud-init v23.4,
  It was reported that the existing code should handle this
  new error code properly.
  This change follows the backwards-compatible approach as described in
  cloud-init documentation[2], by checking that the return code is
  not equal to 1.
- Running status has been changed from "not run" to "not started" in
  cloud-init v24.1 (see [3]).
  This change adds a "not started" match to CLOUDINIT_STATUS_NOT_RUN to
  maintain compatibility.

Addresses Issue: https://github.com/vmware/open-vm-tools/issues/768

[1]: https://cloudinit.readthedocs.io/en/latest/explanation/failure_states.html#error-codes
[2]: https://cloudinit.readthedocs.io/en/latest/explanation/return_codes.html
[3]: https://github.com/canonical/cloud-init/commit/d175170aedc1398b85ac767573b8773a5a2e7c6f

open-vm-tools/libDeployPkg/linuxDeployment.c

index 981ea10f5855d174e13574e93c7e75943ed2f2b4..94a3890ebedcda0130a52609bfceff618851e3c3 100644 (file)
@@ -1315,6 +1315,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";
@@ -1328,13 +1329,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;