From 125c590fddddb038480766283789db4575ce5bba Mon Sep 17 00:00:00 2001 From: Dan Bungert Date: Mon, 24 Jul 2023 14:31:47 -0600 Subject: [PATCH] shutdown: move to command runner The app command runner already knows if we're dry-run or not, so move to that. This allows us to skip more command runs, in particular `journalctl -b`. For my current reboot the integration tests run in half the time! --- subiquity/server/controllers/shutdown.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/subiquity/server/controllers/shutdown.py b/subiquity/server/controllers/shutdown.py index 44961634c..aebd6b6e5 100644 --- a/subiquity/server/controllers/shutdown.py +++ b/subiquity/server/controllers/shutdown.py @@ -25,7 +25,6 @@ ) from subiquitycore.async_helpers import run_bg_task from subiquitycore.context import with_context -from subiquitycore.utils import arun_command, run_command from subiquity.common.apidef import API from subiquity.common.types import ShutdownMode @@ -113,9 +112,9 @@ async def copy_logs_to_target(self, context): if os.path.exists(cloudinit_log) ] if cloudinit_logs: - await arun_command( + await self.app.command_runner.run( ['cp', '-a'] + cloudinit_logs + ['/var/log/installer']) - await arun_command( + await self.app.command_runner.run( ['cp', '-aT', '/var/log/installer', target_logs]) # Close the permissions from group writes on the target. set_log_perms(target_logs, isdir=True, group_write=False) @@ -123,7 +122,7 @@ async def copy_logs_to_target(self, context): journal_txt = os.path.join(target_logs, 'installer-journal.txt') try: with open_perms(journal_txt) as output: - await arun_command( + await self.app.command_runner.run( ['journalctl', '-b'], stdout=output, stderr=subprocess.STDOUT) except Exception: @@ -140,8 +139,9 @@ async def shutdown(self, context): else: if self.app.state == ApplicationState.DONE: if platform.machine() == 's390x': - run_command(["chreipl", "/target/boot"]) + await self.app.command_runner.run( + ["chreipl", "/target/boot"]) if self.mode == ShutdownMode.REBOOT: - run_command(["/sbin/reboot"]) + await self.app.command_runner.run(["/sbin/reboot"]) elif self.mode == ShutdownMode.POWEROFF: - run_command(["/sbin/poweroff"]) + await self.app.command_runner.run(["/sbin/poweroff"])