From e20245ae99ee189fbd4a2a191286cd6cededb2d8 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 23 Nov 2024 14:54:59 +0100 Subject: [PATCH] Drop ForwardJournal= integration for coredumpctl and journalctl verbs Now that we have the sandbox verb, this is trivial to achieve with the sandbox verb so let's keep the coredumpctl and journalctl verbs focused solely on reading the journal and coredumps from the image itself and leave inspecting the forwarded journal to mkosi sandbox. Technically this breaks compat but I'm convinced nobody's actually using this specific bit of integration so it shouldn't matter if we remove it. --- mkosi/__init__.py | 29 ++++++----------------------- mkosi/resources/man/mkosi.1.md | 7 ------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 141518d89..91e71a67a 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3975,16 +3975,12 @@ def run_shell(args: Args, config: Config) -> None: def run_systemd_tool(tool: str, args: Args, config: Config) -> None: - if ( - config.output_format not in (OutputFormat.disk, OutputFormat.directory) - and not config.forward_journal - ): + if config.output_format not in (OutputFormat.disk, OutputFormat.directory): die(f"{config.output_format} images cannot be inspected with {tool}") if ( args.verb in (Verb.journalctl, Verb.coredumpctl) and config.output_format == OutputFormat.disk - and not config.forward_journal and os.getuid() != 0 ): need_root = True @@ -3994,30 +3990,17 @@ def run_systemd_tool(tool: str, args: Args, config: Config) -> None: if (tool_path := config.find_binary(tool)) is None: die(f"Failed to find {tool}") - if config.ephemeral and not config.forward_journal: + if config.ephemeral: die(f"Images booted in ephemeral mode cannot be inspected with {tool}") - output = config.output_dir_or_cwd() / config.output - - if config.forward_journal and not config.forward_journal.exists(): - die( - "Journal directory/file configured with ForwardJournal= does not exist, " - f"cannot inspect with {tool}" - ) - elif not output.exists(): + if not (output := config.output_dir_or_cwd() / config.output).exists(): die( - f"Output {config.output_dir_or_cwd() / config.output} does not exist, cannot inspect with {tool}" + f"Output {output} does not exist, cannot inspect with {tool}", + hint=f"Build and boot the image first before inspecting it with {tool}", ) - cmd: list[PathString] = [tool_path] - - if config.forward_journal: - cmd += ["--directory" if config.forward_journal.is_dir() else "--file", config.forward_journal] - else: - cmd += ["--root" if output.is_dir() else "--image", output] - run( - [*cmd, *args.cmdline], + [tool_path, "--root" if output.is_dir() else "--image", output, *args.cmdline], stdin=sys.stdin, stdout=sys.stdout, env=os.environ | config.environment, diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index 319a5dd33..8fab1c0f6 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -119,18 +119,11 @@ The following command line verbs are known: Any arguments specified after the `journalctl` verb are appended to the `journalctl` invocation. - If `ForwardJournal=` is specified, this verb will operate on the - forwarded journal instead of the journal inside the image. - `coredumpctl` : Uses `coredumpctl` to look for coredumps inside the image. Any arguments specified after the `coredumpctl` verb are appended to the `coredumpctl` invocation. - If `ForwardJournal=` is specified, this verb will operate on the - forwarded journal instead of the image. Note that this requires - configuring systemd-coredump to store coredumps in the journal. - `sysupdate` : Invokes `systemd-sysupdate` with the `--transfer-source=` option set to the output directory and the `--definitions=` option set to the -- 2.47.2