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
1diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
2index 5046eb9..ca0bc10 100644
3--- a/curtin/block/__init__.py
4+++ b/curtin/block/__init__.py
5@@ -227,6 +227,10 @@ def _lsblock_pairs_to_dict(lines):
6 cur = {}
7 for tok in toks:
8 k, v = tok.split("=", 1)
9+ if k == 'MAJ_MIN':
10+ k = 'MAJ:MIN'
11+ else:
12+ k = k.replace('_', '-')
13 cur[k] = v
14 # use KNAME, as NAME may include spaces and other info,
15 # for example, lvm decices may show 'dm0 lvm1'
16diff --git a/tests/unittests/test_block.py b/tests/unittests/test_block.py
17index 519628a..6d9b776 100644
18--- a/tests/unittests/test_block.py
19+++ b/tests/unittests/test_block.py
20@@ -615,6 +615,69 @@ class TestNonAscii(CiTestCase):
21 block.blkid()
22
23
24+class TestLsblkNormalization(CiTestCase):
25+ # In the Jammy timeframe, lsblk changed output such that column names
26+ # that previously contained dashes now have underscores instead.
27+ # _lsblk is expected to normalize this format to the dash style.
28+ # MAJ:MIN was also changed to MAJ_MIN
29+ # impish, and expected format:
30+ # ALIGNMENT="0" DISC-ALN="512" MAJ:MIN="252:0" ...
31+ # jammy:
32+ # ALIGNMENT="0" DISC_ALN="512" MAJ_MIN="252:0" ...
33+ expected = {
34+ 'vda': {
35+ 'ALIGNMENT': "0",
36+ 'DISC-ALN': "512",
37+ 'DISC-GRAN': "512",
38+ 'DISC-MAX': "2147483136",
39+ 'DISC-ZERO': "0",
40+ 'FSTYPE': "",
41+ 'GROUP': "disk",
42+ 'KNAME': "vda",
43+ 'LABEL': "",
44+ 'LOG-SEC': "512",
45+ 'MAJ:MIN': "252:0",
46+ 'MIN-IO': "512",
47+ 'MODE': "brw-rw----",
48+ 'MODEL': "",
49+ 'MOUNTPOINT': "",
50+ 'NAME': "vda",
51+ 'OPT-IO': "0",
52+ 'OWNER': "root",
53+ 'PHY-SEC': "512",
54+ 'RM': "0",
55+ 'RO': "0",
56+ 'ROTA': "1",
57+ 'RQ-SIZE': "256",
58+ 'SIZE': "12884901888",
59+ 'STATE': "",
60+ 'TYPE': "disk",
61+ 'UUID': "",
62+ 'device_path': '/dev/vda'
63+ }
64+ }
65+
66+ def test_lsblk_impish_style(self):
67+ line = ('ALIGNMENT="0" DISC-ALN="512" DISC-GRAN="512" '
68+ 'DISC-MAX="2147483136" DISC-ZERO="0" FSTYPE="" GROUP="disk" '
69+ 'KNAME="vda" LABEL="" LOG-SEC="512" MAJ:MIN="252:0" '
70+ 'MIN-IO="512" MODE="brw-rw----" MODEL="" MOUNTPOINT="" '
71+ 'NAME="vda" OPT-IO="0" OWNER="root" PHY-SEC="512" RM="0" '
72+ 'RO="0" ROTA="1" RQ-SIZE="256" SIZE="12884901888" STATE="" '
73+ 'TYPE="disk" UUID=""')
74+ self.assertEqual(self.expected, block._lsblock_pairs_to_dict(line))
75+
76+ def test_lsblk_jammy_style(self):
77+ line = ('ALIGNMENT="0" DISC_ALN="512" DISC_GRAN="512" '
78+ 'DISC_MAX="2147483136" DISC_ZERO="0" FSTYPE="" GROUP="disk" '
79+ 'KNAME="vda" LABEL="" LOG_SEC="512" MAJ_MIN="252:0" '
80+ 'MIN_IO="512" MODE="brw-rw----" MODEL="" MOUNTPOINT="" '
81+ 'NAME="vda" OPT_IO="0" OWNER="root" PHY_SEC="512" RM="0" '
82+ 'RO="0" ROTA="1" RQ_SIZE="256" SIZE="12884901888" STATE="" '
83+ 'TYPE="disk" UUID=""')
84+ self.assertEqual(self.expected, block._lsblock_pairs_to_dict(line))
85+
86+
87 class TestSlaveKnames(CiTestCase):
88
89 def setUp(self):

Subscribers

People subscribed via source and target branches