From 68316ceb807c0db88341e6735e1d346c807b18ee Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Fri, 11 Nov 2022 15:07:25 +1300 Subject: [PATCH 1/2] force storage version to 2 for a core boot classic install also a barely-related tweak to more accurately decide which path to take in installation --- subiquity/server/controllers/filesystem.py | 32 ++++++++++++------- subiquity/server/controllers/install.py | 4 +-- .../controllers/tests/test_filesystem.py | 3 ++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index 8ad6fa42..94c5e8ac 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -145,6 +145,9 @@ class FilesystemController(SubiquityController, FilesystemManipulator): self._role_to_device: Dict[snapdapi.Role: _Device] = {} self.use_tpm: bool = False + def is_core_boot_classic(self): + return self._system is not None + def load_autoinstall_data(self, data): log.debug("load_autoinstall_data %s", data) if data is None: @@ -180,24 +183,29 @@ class FilesystemController(SubiquityController, FilesystemManipulator): async def _get_system(self): await self._unmount_system() await self._mount_system() + self._system = None label = self.app.base_model.source.current.snapd_system_label - if label is None: + if label is not None: + self._system = await self.app.snapdapi.v2.systems[label].GET() + log.debug("got system %s", self._system) + if len(self._system.volumes) == 0: + # This means the system does not define a gadget or kernel and + # so isn't a core boot classic system. + self._system = None + if self._system is None: + await self._unmount_system() + self.model.storage_version = self.opts.storage_version self._system = None return - system = await self.app.snapdapi.v2.systems[label].GET() - log.debug("got system %s", system) - if len(system.volumes) == 0: - # This means the system does not define a gadget or kernel - # so isn't a core boot classic system. - await self._unmount_system() - return - self._system = system - if len(system.volumes) > 1: + # Formatting for a core boot classic system relies on some curtin + # features that are only available with v2 partitioning. + self.model.storage_version = 2 + if len(self._system.volumes) > 1: self._core_boot_classic_error = system_multiple_volumes_text - [volume] = system.volumes.values() + [volume] = self._system.volumes.values() if volume.schema != 'gpt': self._core_boot_classic_error = system_non_gpt_text - if system.storage_encryption.support == \ + if self._system.storage_encryption.support == \ StorageEncryptionSupport.DEFECTIVE: self._core_boot_classic_error = system_defective_encryption_text diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index d20fa9bb..13b3b005 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -257,8 +257,8 @@ class InstallController(SubiquityController): acquire_config=self.acquire_initial_config ).run, ] - if self.model.source.current.snapd_system_label: - fs_controller = self.app.controllers.Filesystem + fs_controller = self.app.controllers.Filesystem + if fs_controller.is_core_boot_classic(): steps.append( make_curtin_step( name="partitioning", stages=["partitioning"], diff --git a/subiquity/server/controllers/tests/test_filesystem.py b/subiquity/server/controllers/tests/test_filesystem.py index 4814b9c2..7786c561 100644 --- a/subiquity/server/controllers/tests/test_filesystem.py +++ b/subiquity/server/controllers/tests/test_filesystem.py @@ -525,6 +525,9 @@ class TestCoreBootInstallMethods(IsolatedAsyncioTestCase): self.app.controllers.Source.source_path = '' await self.fsc._get_system_task.start() await self.fsc._get_system_task.wait() + + self.assertEqual(model.storage_version, 2) + self.fsc.apply_system(disk.id) partition_count = len([ structure From 97d4fd70cdd3132f569b94a953e971c3ea7d1a2c Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Fri, 11 Nov 2022 16:24:39 +1300 Subject: [PATCH 2/2] another comment for future work --- subiquity/server/controllers/install.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index 13b3b005..2396955e 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -305,6 +305,10 @@ class InstallController(SubiquityController): acquire_config=self.acquire_generic_config, ).run, ]) + # If the current source has a snapd_system_label here we should + # really write recovery_system={snapd_system_label} to + # {target}/var/lib/snapd/modeenv to get snapd to pick it up on + # first boot. But not needed for now. for step in steps: await step(context=context)