From 20bd192db661e519b860a0799de04c663ceae0c6 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Tue, 18 Jan 2022 20:46:14 -0700 Subject: [PATCH] cmd: status and cloud-id avoid change in behavior for 'not run' (#1197) snapd currrently looks for 'not run' from cloud-init status[1]. Avoid changing this behavior and revert "not-run" value to "not run". This avoids having to get snapd to change implementation and release updates as far back as Bionic to handle a hyphenated not-run string. [1]: https://github.com/snapcore/snapd/blob/master/sysconfig/\ cloudinit.go#L802 --- cloudinit/cmd/cloud_id.py | 2 +- cloudinit/cmd/status.py | 2 +- doc/man/cloud-id.1 | 2 +- tests/unittests/cmd/test_status.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cloudinit/cmd/cloud_id.py b/cloudinit/cmd/cloud_id.py index b71c19decea..b9c30fb4cb8 100755 --- a/cloudinit/cmd/cloud_id.py +++ b/cloudinit/cmd/cloud_id.py @@ -63,7 +63,7 @@ def handle_args(name, args): Print the canonical cloud-id on which the instance is running. - @return: 0 on success, 1 on error, 2 on disabled, 3 on cloud-init not-run. + @return: 0 on success, 1 on error, 2 on disabled, 3 on cloud-init not run. """ status, _status_details, _time = get_status_details() if status == UXAppStatus.DISABLED: diff --git a/cloudinit/cmd/status.py b/cloudinit/cmd/status.py index 597e5bfbc01..5176549dd51 100644 --- a/cloudinit/cmd/status.py +++ b/cloudinit/cmd/status.py @@ -22,7 +22,7 @@ class UXAppStatus(enum.Enum): """Enum representing user-visible cloud-init application status.""" - NOT_RUN = "not-run" + NOT_RUN = "not run" RUNNING = "running" DONE = "done" ERROR = "error" diff --git a/doc/man/cloud-id.1 b/doc/man/cloud-id.1 index c56587c8f19..cb500189c33 100644 --- a/doc/man/cloud-id.1 +++ b/doc/man/cloud-id.1 @@ -9,7 +9,7 @@ cloud-id \- Report the canonical cloud-id for this instance .SH DESCRIPTION cloud-id is the lowercase name of the cloud datasource discovered. -The cloud-id will be 'not-run' when systemd generator has not run yet. +The cloud-id will be 'not run' when systemd generator has not run yet. The cloud-id will be 'disabled' when cloud-init is disabled or when ds-identify did not find a valid datasource. diff --git a/tests/unittests/cmd/test_status.py b/tests/unittests/cmd/test_status.py index 17d275979f7..c5f424da812 100644 --- a/tests/unittests/cmd/test_status.py +++ b/tests/unittests/cmd/test_status.py @@ -137,7 +137,7 @@ def test__is_cloudinit_disabled_false_when_enabled_in_systemd(self): ) def test_status_returns_not_run(self): - """When status.json does not exist yet, return 'not-run'.""" + """When status.json does not exist yet, return 'not run'.""" self.assertFalse( os.path.exists(self.status_file), "Unexpected status.json found" ) @@ -154,7 +154,7 @@ def test_status_returns_not_run(self): cmdargs, ) self.assertEqual(0, retcode) - self.assertEqual("status: not-run\n", m_stdout.getvalue()) + self.assertEqual("status: not run\n", m_stdout.getvalue()) def test_status_returns_disabled_long_on_presence_of_disable_file(self): """When cloudinit is disabled, return disabled reason."""