Skip to content

Commit

Permalink
shutdown: move to command runner
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
dbungert committed Jul 24, 2023
1 parent e84b3dd commit 125c590
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions subiquity/server/controllers/shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -113,17 +112,17 @@ 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)

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:
Expand All @@ -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"])

0 comments on commit 125c590

Please sign in to comment.