Merge ~raharper/curtin:fix/zfsroot-export-zpools-after-install into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: 8c362d2e8dcfb26792c7978f6528c90e9845d48a
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/curtin:fix/zfsroot-export-zpools-after-install
Merge into: curtin:master
Diff against target: 112 lines (+55/-3)
4 files modified
curtin/block/zfs.py (+24/-0)
curtin/commands/install.py (+5/-1)
tests/unittests/test_block_zfs.py (+26/-0)
tests/vmtests/test_zfsroot.py (+0/-2)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+372913@code.launchpad.net

Commit message

install: export zpools if present in the storage-config

Curtin needs to run zpool export on the any pool it created
before booting as zfs-initramfs 0.8 now requires a pool to
be exported before being imported.

LP: #1838278

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
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 :

You should mention in commit message that you're putting /run into all chroots now.

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

> You should mention in commit message that you're putting /run into all chroots
> now.

Fixed now; I didn't mean to include that in this merge. I'll put the /run one up separately.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
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 :

vmtest shows that the fstype: zfsroot scenario needs a fix too.

Revision history for this message
Dan Watkins (oddbloke) :
Revision history for this message
Ryan Harper (raharper) wrote :

Thanks, I'll fix up the early return. And I need to add a fix for the zfsroot fstype case.

Revision history for this message
Dan Watkins (oddbloke) :
Revision history for this message
Ryan Harper (raharper) wrote :

Computer says "Yes!"

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

----------------------------------------------------------------------
Ran 182 tests in 1687.305s

OK (SKIP=28)
Wed, 18 Sep 2019 13:15:40 +0000: vmtest end [0] in 1690s

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

The /run change got moved https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/372942

Thanks for separating.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Thanks for this, looks good Ryan, just one question about limiting where we need to do this to Eoan ++,

review: Needs Information
Revision history for this message
Ryan Harper (raharper) :
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 on this. Thanks for the response.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/curtin/block/zfs.py b/curtin/block/zfs.py
index dce15c3..25751d3 100644
--- a/curtin/block/zfs.py
+++ b/curtin/block/zfs.py
@@ -281,4 +281,28 @@ def device_to_poolname(devname):
281 if vdev_type == 'zfs_member' and label:281 if vdev_type == 'zfs_member' and label:
282 return label282 return label
283283
284
285def get_zpool_from_config(cfg):
286 """Parse a curtin storage config and return a list
287 of zpools that were created.
288 """
289 if not cfg:
290 return []
291
292 if 'storage' not in cfg:
293 return []
294
295 zpools = []
296 sconfig = cfg['storage']['config']
297 for item in sconfig:
298 if item['type'] == 'zpool':
299 zpools.append(item['pool'])
300 elif item['type'] == 'format':
301 if item['fstype'] == 'zfsroot':
302 # curtin.commands.blockmeta sets pool='rpool' for zfsroot
303 zpools.append('rpool')
304
305 return zpools
306
307
284# vi: ts=4 expandtab syntax=python308# vi: ts=4 expandtab syntax=python
diff --git a/curtin/commands/install.py b/curtin/commands/install.py
index ad17508..a3471f6 100644
--- a/curtin/commands/install.py
+++ b/curtin/commands/install.py
@@ -11,7 +11,7 @@ import subprocess
11import sys11import sys
12import tempfile12import tempfile
1313
14from curtin.block import iscsi14from curtin.block import iscsi, zfs
15from curtin import config15from curtin import config
16from curtin import distro16from curtin import distro
17from curtin import util17from curtin import util
@@ -505,6 +505,10 @@ def cmd_install(args):
505 if iscsi.get_iscsi_disks_from_config(cfg):505 if iscsi.get_iscsi_disks_from_config(cfg):
506 iscsi.restart_iscsi_service()506 iscsi.restart_iscsi_service()
507507
508 for pool in zfs.get_zpool_from_config(cfg):
509 LOG.debug('Exporting ZFS zpool %s', pool)
510 zfs.zpool_export(pool)
511
508 shutil.rmtree(workingd.top)512 shutil.rmtree(workingd.top)
509513
510 apply_power_state(cfg.get('power_state'))514 apply_power_state(cfg.get('power_state'))
diff --git a/tests/unittests/test_block_zfs.py b/tests/unittests/test_block_zfs.py
index f45fde2..3508d4b 100644
--- a/tests/unittests/test_block_zfs.py
+++ b/tests/unittests/test_block_zfs.py
@@ -538,4 +538,30 @@ class TestZfsSupported(CiTestCase):
538 self.assertEqual(1, m_assert_zfs.call_count)538 self.assertEqual(1, m_assert_zfs.call_count)
539539
540540
541class TestZfsGetPoolFromConfig(CiTestCase):
542
543 def test_get_zpool_from_config_returns_empty(self):
544 """ get_zpool_from_config_returns_empty for invalid/empty configs."""
545 configs = (None, {}, {'network': 'foobar'},
546 {'storage': {'config': []}})
547 for cfg in configs:
548 self.assertEqual([],
549 zfs.get_zpool_from_config(cfg))
550
551 def test_get_zpool_from_config(self):
552 """ get_zpool_from_config_returns pool names for each zpool in cfg."""
553 expected_zpools = ['rpool1', 'rpool2']
554 zpool_cfg = [{'type': 'zpool', 'pool': pool}
555 for pool in expected_zpools]
556 sconfig = {'storage': {'config': zpool_cfg}}
557 self.assertEqual(sorted(expected_zpools),
558 sorted(zfs.get_zpool_from_config(sconfig)))
559
560 def test_get_zpool_from_config_zfsroot(self):
561 """ get_zpool_from_config_returns injected pool name for zfsroot."""
562 zpool_cfg = [{'type': 'format', 'fstype': 'zfsroot'}]
563 sconfig = {'storage': {'config': zpool_cfg}}
564 self.assertEqual(['rpool'], zfs.get_zpool_from_config(sconfig))
565
566
541# vi: ts=4 expandtab syntax=python567# vi: ts=4 expandtab syntax=python
diff --git a/tests/vmtests/test_zfsroot.py b/tests/vmtests/test_zfsroot.py
index a2fc316..a0e50e9 100644
--- a/tests/vmtests/test_zfsroot.py
+++ b/tests/vmtests/test_zfsroot.py
@@ -99,7 +99,6 @@ class DiscoTestZfsRoot(relbase.disco, TestZfsRootAbs):
99 mem = 409699 mem = 4096
100100
101101
102@TestZfsRootAbs.skip_by_date("1838278", fixby="2019-10-01", install=False)
103class EoanTestZfsRoot(relbase.eoan, TestZfsRootAbs):102class EoanTestZfsRoot(relbase.eoan, TestZfsRootAbs):
104 __test__ = True103 __test__ = True
105 mem = 4096104 mem = 4096
@@ -129,7 +128,6 @@ class DiscoTestZfsRootFsType(relbase.disco, TestZfsRootFsTypeAbs):
129 mem = 4096128 mem = 4096
130129
131130
132@TestZfsRootAbs.skip_by_date("1838278", fixby="2019-10-01", install=False)
133class EoanTestZfsRootFsType(relbase.eoan, TestZfsRootFsTypeAbs):131class EoanTestZfsRootFsType(relbase.eoan, TestZfsRootFsTypeAbs):
134 __test__ = True132 __test__ = True
135 mem = 4096133 mem = 4096

Subscribers

People subscribed via source and target branches