Merge ~dbungert/curtin:udi-513 into curtin:master

Proposed by Dan Bungert
Status: Merged
Approved by: Dan Bungert
Approved revision: 37945f5ddee4f4ea8258e6a7f99d3c686fb4fbea
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~dbungert/curtin:udi-513
Merge into: curtin:master
Diff against target: 89 lines (+67/-0)
2 files modified
curtin/block/__init__.py (+4/-0)
tests/unittests/test_block.py (+63/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
curtin developers Pending
Review via email: mp+412027@code.launchpad.net

Commit message

lsblk: adjust output to match old format

The version of lsblk in Jammy, utils-linux 2.37.2,
has a modified output format from what curtin is expecting.
Normalize that format to the older style.
This appears to be the root cause for install failures of u-d-i
as reported in
https://github.com/canonical/ubuntu-desktop-installer/issues/513

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
Michael Hudson-Doyle (mwhudson) wrote :

I'm not here today but is there any scope for moving curtin to a model of
not relying on lsblk output? I.e. get the information it needs from sysfs
or udev or whatever more directly?

On Thu, 18 Nov 2021, 07:42 Server Team CI bot, <email address hidden>
wrote:

> Review: Approve continuous-integration
>
> PASSED: Continuous integration,
> rev:37945f5ddee4f4ea8258e6a7f99d3c686fb4fbea
> https://jenkins.ubuntu.com/server/job/curtin-ci/200/
> Executed test runs:
> SUCCESS:
> https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-amd64/200/
> SUCCESS:
> https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-arm64/200/
> SUCCESS:
> https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-ppc64el/200/
> SUCCESS:
> https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-s390x/200/
>
>
> Click here to trigger a rebuild:
> https://jenkins.ubuntu.com/server/job/curtin-ci/200//rebuild
> --
> https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/412027
> You are subscribed to branch curtin:master.
>
>

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

Commit message lints:
- Expected empty line on line 2 of the commit message

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
index 5046eb9..ca0bc10 100644
--- a/curtin/block/__init__.py
+++ b/curtin/block/__init__.py
@@ -227,6 +227,10 @@ def _lsblock_pairs_to_dict(lines):
227 cur = {}227 cur = {}
228 for tok in toks:228 for tok in toks:
229 k, v = tok.split("=", 1)229 k, v = tok.split("=", 1)
230 if k == 'MAJ_MIN':
231 k = 'MAJ:MIN'
232 else:
233 k = k.replace('_', '-')
230 cur[k] = v234 cur[k] = v
231 # use KNAME, as NAME may include spaces and other info,235 # use KNAME, as NAME may include spaces and other info,
232 # for example, lvm decices may show 'dm0 lvm1'236 # for example, lvm decices may show 'dm0 lvm1'
diff --git a/tests/unittests/test_block.py b/tests/unittests/test_block.py
index 519628a..6d9b776 100644
--- a/tests/unittests/test_block.py
+++ b/tests/unittests/test_block.py
@@ -615,6 +615,69 @@ class TestNonAscii(CiTestCase):
615 block.blkid()615 block.blkid()
616616
617617
618class TestLsblkNormalization(CiTestCase):
619 # In the Jammy timeframe, lsblk changed output such that column names
620 # that previously contained dashes now have underscores instead.
621 # _lsblk is expected to normalize this format to the dash style.
622 # MAJ:MIN was also changed to MAJ_MIN
623 # impish, and expected format:
624 # ALIGNMENT="0" DISC-ALN="512" MAJ:MIN="252:0" ...
625 # jammy:
626 # ALIGNMENT="0" DISC_ALN="512" MAJ_MIN="252:0" ...
627 expected = {
628 'vda': {
629 'ALIGNMENT': "0",
630 'DISC-ALN': "512",
631 'DISC-GRAN': "512",
632 'DISC-MAX': "2147483136",
633 'DISC-ZERO': "0",
634 'FSTYPE': "",
635 'GROUP': "disk",
636 'KNAME': "vda",
637 'LABEL': "",
638 'LOG-SEC': "512",
639 'MAJ:MIN': "252:0",
640 'MIN-IO': "512",
641 'MODE': "brw-rw----",
642 'MODEL': "",
643 'MOUNTPOINT': "",
644 'NAME': "vda",
645 'OPT-IO': "0",
646 'OWNER': "root",
647 'PHY-SEC': "512",
648 'RM': "0",
649 'RO': "0",
650 'ROTA': "1",
651 'RQ-SIZE': "256",
652 'SIZE': "12884901888",
653 'STATE': "",
654 'TYPE': "disk",
655 'UUID': "",
656 'device_path': '/dev/vda'
657 }
658 }
659
660 def test_lsblk_impish_style(self):
661 line = ('ALIGNMENT="0" DISC-ALN="512" DISC-GRAN="512" '
662 'DISC-MAX="2147483136" DISC-ZERO="0" FSTYPE="" GROUP="disk" '
663 'KNAME="vda" LABEL="" LOG-SEC="512" MAJ:MIN="252:0" '
664 'MIN-IO="512" MODE="brw-rw----" MODEL="" MOUNTPOINT="" '
665 'NAME="vda" OPT-IO="0" OWNER="root" PHY-SEC="512" RM="0" '
666 'RO="0" ROTA="1" RQ-SIZE="256" SIZE="12884901888" STATE="" '
667 'TYPE="disk" UUID=""')
668 self.assertEqual(self.expected, block._lsblock_pairs_to_dict(line))
669
670 def test_lsblk_jammy_style(self):
671 line = ('ALIGNMENT="0" DISC_ALN="512" DISC_GRAN="512" '
672 'DISC_MAX="2147483136" DISC_ZERO="0" FSTYPE="" GROUP="disk" '
673 'KNAME="vda" LABEL="" LOG_SEC="512" MAJ_MIN="252:0" '
674 'MIN_IO="512" MODE="brw-rw----" MODEL="" MOUNTPOINT="" '
675 'NAME="vda" OPT_IO="0" OWNER="root" PHY_SEC="512" RM="0" '
676 'RO="0" ROTA="1" RQ_SIZE="256" SIZE="12884901888" STATE="" '
677 'TYPE="disk" UUID=""')
678 self.assertEqual(self.expected, block._lsblock_pairs_to_dict(line))
679
680
618class TestSlaveKnames(CiTestCase):681class TestSlaveKnames(CiTestCase):
619682
620 def setUp(self):683 def setUp(self):

Subscribers

People subscribed via source and target branches