From f9b340026f340672d085d4ee72330499b0813185 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 9 Sep 2024 10:35:42 +0200 Subject: [PATCH] filesystem: document _pre_shutdown and link to systemd-shutdown impl We decided to revert the use of systemd-shutdown for exporting zpools because it didn't address the issue we were trying to solve. However, dropping scripts for systemd-shutdown is an interesting implementation from an architecture standpoint, because it can be executed even if Subiquity does not cleanly exit. Let's document the _pre_shutdown function and link to the original systemd-shutdown implementation that we came up with for exporting zpools earlier. Signed-off-by: Olivier Gayot (cherry picked from commit f36c828debaea61e6649c3f938e92f57f6b94016) --- subiquity/server/controllers/filesystem.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index f79d08b2d..a9cc78bea 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -1633,6 +1633,19 @@ def make_autoinstall(self): return r async def _pre_shutdown(self): + """This function is executed just before rebooting and after copying + logs to the target. This means bugs reports are unlikely to include + execution logs from this function and therefore diagnosing issues is a + challenge. Let's try to keep it as simple as possible. + + Another approach to execute commands before reboot is to place scripts in + /usr/lib/systemd/system-shutdown and lean on systemd-shutdown(8) to + execute them after unmounting most file-systems. + + See this PR for an example (the PR was eventually reverted because it + didn't address the issue we tried to solve at the time). + https://github.com/canonical/subiquity/pull/2064 + """ if not self.reset_partition_only: # /target is mounted only if the installation was actually started. try: