From 5564cdf70f6ae89e8f2301c78127d5113f75cd05 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Thu, 2 May 2024 11:37:45 -0600 Subject: [PATCH] wip --- cloudinit/cmd/main.py | 14 +++++++++++--- tests/unittests/test_cli.py | 11 +++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py index 0457746090b..f3850f0bfb7 100644 --- a/cloudinit/cmd/main.py +++ b/cloudinit/cmd/main.py @@ -56,6 +56,14 @@ "once": PER_ONCE, } +# https://cloudinit.readthedocs.io/en/latest/explanation/boot.html +STAGE_NAME = { + "init-local": "Local Stage", + "init": "Network Stage", + "modules-config": "Config Stage", + "modules-final": "Final Stage", +} + LOG = logging.getLogger(__name__) @@ -749,7 +757,7 @@ def status_wrapper(name, args): nullstatus = { "errors": [], - "recoverable_errors": [], + "recoverable_errors": {}, "start": None, "finished": None, } @@ -780,8 +788,8 @@ def status_wrapper(name, args): if v1[mode]["start"] and not v1[mode]["finished"]: # This stage was restarted, which isn't expected. LOG.warning( - "Unexpected start time for stage %s. " "Was this stage restarted?", - mode, + "Unexpected start time found for %s. " "Was this stage restarted?", + STAGE_NAME[mode], ) v1[mode]["start"] = float(util.uptime()) diff --git a/tests/unittests/test_cli.py b/tests/unittests/test_cli.py index 909f700858a..c234eadc302 100644 --- a/tests/unittests/test_cli.py +++ b/tests/unittests/test_cli.py @@ -498,25 +498,25 @@ def test_status_wrapper_signal_warnings( ), "init": { "errors": [], - "recoverable_errors": [], + "recoverable_errors": {}, "start": 124.567, "finished": None, }, "init-local": { "errors": [], - "recoverable_errors": [], + "recoverable_errors": {}, "start": 100.0, "finished": 100.00001, }, "modules-config": { "errors": [], - "recoverable_errors": [], + "recoverable_errors": {}, "start": None, "finished": None, }, "modules-final": { "errors": [], - "recoverable_errors": [], + "recoverable_errors": {}, "start": None, "finished": None, }, @@ -540,8 +540,7 @@ def test_status_wrapper_signal_warnings( # assert that the status shows recoverable errors assert ( - "[init] Unexpected value found in status.json. " - "Was this stage restarted?" + 'Unexpected start time found for Network Stage. Was this stage restarted?' in m_json.call_args[0][1]["v1"]["init"]["recoverable_errors"][ "WARNING" ]