Merge ~raharper/curtin:fix/zfs-export-online-pool-only into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: a53333511d3119a80f1f3bf2b02a874dbef5b9eb
Merge reported by: Ryan Harper
Merged at revision: 736808c0b46dd0d677609694700b61ad748c384a
Proposed branch: ~raharper/curtin:fix/zfs-export-online-pool-only
Merge into: curtin:master
Diff against target: 73 lines (+15/-2)
5 files modified
curtin/block/clear_holders.py (+3/-1)
curtin/block/zfs.py (+1/-1)
examples/tests/dirty_disks_config.yaml (+6/-0)
tests/unittests/test_clear_holders.py (+1/-0)
tests/vmtests/test_zfsroot.py (+4/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Scott Moser (community) Approve
Review via email: mp+345324@code.launchpad.net

Commit message

clear_holders: only export zpools that have been imported

Curtin may encounter disks from a previous install which are
zfs_members but are part of a pool which isn't currently
imported. Attempting to export a pool that is not imported
results in a failure. Instead, only export a pool if it's
found in the list of currently imported pools.

Also enable Bionic ZfsRoot vmtest (BionicTestZfsRootFsType)
LP: #1770280

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

I approve with the following:
a.) update commit message to indicate that "may encounter" is
  may encounter from data from a previous install.
b.) enable BionicZfs test
c.) run vmtest of BionicZfs and ZfsRoot to verify

review: Approve
Revision history for this message
Ryan Harper (raharper) wrote :

a) done
b) already in tests_zfsroot.py, we had only missed the ZfsRootFs case, which this branch adds
c) started:

https://jenkins.ubuntu.com/server/view/curtin/job/curtin-vmtest-devel-debug/59/console

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :
Revision history for this message
Ryan Harper (raharper) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/curtin/commit/?id=736808c0

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/block/clear_holders.py b/curtin/block/clear_holders.py
2index d697f9b..e0ee044 100644
3--- a/curtin/block/clear_holders.py
4+++ b/curtin/block/clear_holders.py
5@@ -251,7 +251,9 @@ def wipe_superblock(device):
6 # release zfs member by exporting the pool
7 if block.is_zfs_member(blockdev):
8 poolname = zfs.device_to_poolname(blockdev)
9- zfs.zpool_export(poolname)
10+ # only export pools that have been imported
11+ if poolname in zfs.zpool_list():
12+ zfs.zpool_export(poolname)
13
14 if is_swap_device(blockdev):
15 shutdown_swap(blockdev)
16diff --git a/curtin/block/zfs.py b/curtin/block/zfs.py
17index 7670af4..8e00c7e 100644
18--- a/curtin/block/zfs.py
19+++ b/curtin/block/zfs.py
20@@ -184,7 +184,7 @@ def zfs_mount(poolname, volume):
21
22 def zpool_list():
23 """
24- Return a list of zfs pool names
25+ Return a list of zfs pool names which have been imported
26
27 :returns: List of strings
28 """
29diff --git a/examples/tests/dirty_disks_config.yaml b/examples/tests/dirty_disks_config.yaml
30index 18d331d..75d44c3 100644
31--- a/examples/tests/dirty_disks_config.yaml
32+++ b/examples/tests/dirty_disks_config.yaml
33@@ -22,6 +22,11 @@ bucket:
34 done
35 swapon --show
36 exit 0
37+ - &zpool_export |
38+ #!/bin/sh
39+ # disable any rpools to trigger disks with zfs_member label but inactive
40+ # pools
41+ zpool export rpool ||:
42
43 early_commands:
44 # running block-meta custom from the install environment
45@@ -34,3 +39,4 @@ early_commands:
46 WORKING_DIR=/tmp/my.bdir/work.d,
47 curtin, --showtrace, -v, block-meta, --umount, custom]
48 enable_swaps: [sh, -c, *swapon]
49+ disable_rpool: [sh, -c, *zpool_export]
50diff --git a/tests/unittests/test_clear_holders.py b/tests/unittests/test_clear_holders.py
51index 183cd20..ddb149f 100644
52--- a/tests/unittests/test_clear_holders.py
53+++ b/tests/unittests/test_clear_holders.py
54@@ -510,6 +510,7 @@ class TestClearHolders(CiTestCase):
55 mock_block.is_extended_partition.return_value = False
56 mock_block.is_zfs_member.return_value = True
57 mock_zfs.device_to_poolname.return_value = 'fake_pool'
58+ mock_zfs.zpool_list.return_value = ['fake_pool']
59 clear_holders.wipe_superblock(self.test_syspath)
60 mock_block.sysfs_to_devpath.assert_called_with(self.test_syspath)
61 mock_zfs.zpool_export.assert_called_with('fake_pool')
62diff --git a/tests/vmtests/test_zfsroot.py b/tests/vmtests/test_zfsroot.py
63index 4487185..84439d3 100644
64--- a/tests/vmtests/test_zfsroot.py
65+++ b/tests/vmtests/test_zfsroot.py
66@@ -81,3 +81,7 @@ class TestZfsRootFsTypeAbs(TestZfsRootAbs):
67
68 class XenialGATestZfsRootFsType(relbase.xenial_ga, TestZfsRootFsTypeAbs):
69 __test__ = True
70+
71+
72+class BionicTestZfsRootFsType(relbase.bionic, TestZfsRootFsTypeAbs):
73+ __test__ = True

Subscribers

People subscribed via source and target branches