Skip to content

Commit

Permalink
cmd: status and cloud-id avoid change in behavior for 'not run' (#1197)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
blackboxsw authored Jan 19, 2022
1 parent c2c2a66 commit 20bd192
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cloudinit/cmd/cloud_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/cmd/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion doc/man/cloud-id.1
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/cmd/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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."""
Expand Down

0 comments on commit 20bd192

Please sign in to comment.