diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index fdd4029d1..5d168942b 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -1781,5 +1781,4 @@ async def _pre_shutdown(self): ) else: await self.app.command_runner.run(["umount", "--recursive", "/target"]) - if len(self.model._all(type="zpool")) > 0: - await self.app.command_runner.run(["zpool", "export", "-a"]) + await self.app.command_runner.run(["zpool", "export", "-a"]) diff --git a/subiquity/server/controllers/tests/test_filesystem.py b/subiquity/server/controllers/tests/test_filesystem.py index 97b9ae7ba..84f8fec1f 100644 --- a/subiquity/server/controllers/tests/test_filesystem.py +++ b/subiquity/server/controllers/tests/test_filesystem.py @@ -468,9 +468,10 @@ async def test__pre_shutdown_install_started(self): [ mock.call(["mountpoint", "/target"]), mock.call(["umount", "--recursive", "/target"]), + mock.call(["zpool", "export", "-a"]), ] ) - self.assertEqual(len(mock_run.mock_calls), 2) + self.assertEqual(3, mock_run.call_count) async def test__pre_shutdown_install_not_started(self): async def fake_run(cmd, **kwargs): @@ -479,10 +480,15 @@ async def fake_run(cmd, **kwargs): self.fsc.reset_partition_only = False run = mock.patch.object(self.app.command_runner, "run", side_effect=fake_run) - _all = mock.patch.object(self.fsc.model, "_all") - with run as mock_run, _all: + with run as mock_run: await self.fsc._pre_shutdown() - mock_run.assert_called_once_with(["mountpoint", "/target"]) + mock_run.assert_has_calls( + [ + mock.call(["mountpoint", "/target"]), + mock.call(["zpool", "export", "-a"]), + ] + ) + self.assertEqual(2, mock_run.call_count) async def test_examine_systems(self): # In LP: #2037723 and other similar reports, the user selects the