Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: Don't write json status files for non-boot stages #4478

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cloudinit/cmd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ def status_wrapper(name, args, data_d=None, link_d=None):
modes = (
"init",
"init-local",
"modules-init",
"modules-config",
"modules-final",
)
Expand Down Expand Up @@ -1059,7 +1058,10 @@ def main(sysv_args=None):
# Setup signal handlers before running
signal_handler.attach_handlers()

if name in ("modules", "init"):
# Write boot stage data to write status.json and result.json
# Exclude modules --mode=init, since it is not a real boot stage and
# should not be written into status.json
if "init" == name or ("modules" == name and "init" != args.mode):
functor = status_wrapper

rname = None
Expand Down
8 changes: 8 additions & 0 deletions tests/unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ def myaction(name, args):
cli.status_wrapper("init", myargs, data_d, link_d)
# No errors reported in status
status_v1 = m_json.call_args_list[1][0][1]["v1"]
assert status_v1.keys() == {
"datasource",
"init-local",
"init",
"modules-config",
"modules-final",
"stage",
}
assert ["an error"] == status_v1["init-local"]["errors"]
assert "SomeDatasource" == status_v1["datasource"]
assert False is os.path.exists(
Expand Down
Loading