Merge ~raharper/curtin:fix/get_part_table_type into curtin:master

Proposed by Ryan Harper
Status: Rejected
Rejected by: Ryan Harper
Proposed branch: ~raharper/curtin:fix/get_part_table_type
Merge into: curtin:master
Diff against target: 51 lines (+18/-2)
2 files modified
curtin/block/__init__.py (+3/-0)
tests/unittests/test_block.py (+15/-2)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Chad Smith Pending
Review via email: mp+382440@code.launchpad.net

Commit message

block: check for fdasd command before using

When probing for vtoc partition table type; this uses fdasd command
which is only present on s390x; return False if we do not have the
command available.

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
Chad Smith (chad.smith) wrote :

Is this general intent to improve execution speed by checking which first before running subp? I don't see how this would emit an unhandled traceback otherwise

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

Hrm... You're right; I saw fdasd execution in the trace; but I bet you're right that it's not needed.

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

The other fix which skips checking the part table type if ptable is not present will fix the issue I saw. And on non-s390x, you're right we'll run fdasd, fail, and return False.

Unmerged commits

d452311... by Ryan Harper

block: check for fdasd command before using

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 aa5c6f7..2c7cc0e 100644
3--- a/curtin/block/__init__.py
4+++ b/curtin/block/__init__.py
5@@ -962,6 +962,9 @@ def check_efi_signature(device):
6
7 def check_vtoc_signature(device):
8 """ check if the specified device has a vtoc partition table. """
9+ if not util.which('fdasd'):
10+ return False
11+
12 devname = dev_path(path_to_kname(device))
13 try:
14 util.subp(['fdasd', '--table', devname])
15diff --git a/tests/unittests/test_block.py b/tests/unittests/test_block.py
16index 8ba8333..ab13d65 100644
17--- a/tests/unittests/test_block.py
18+++ b/tests/unittests/test_block.py
19@@ -567,17 +567,30 @@ class TestPartTableSignature(CiTestCase):
20 (self.assertTrue if expected else self.assertFalse)(
21 block.check_efi_signature(self.blockdev))
22
23+ @mock.patch('curtin.block.util.which')
24 @mock.patch('curtin.block.util.subp')
25- def test_check_vtoc_signature_finds_vtoc_returns_true(self, mock_subp):
26+ def test_check_vtoc_signature_finds_vtoc_returns_true(self, mock_subp,
27+ mock_which):
28+ mock_which.return_value = True
29 mock_subp.return_value = ("vtoc.....ok", "")
30 self.assertTrue(block.check_vtoc_signature(self.blockdev))
31
32+ @mock.patch('curtin.block.util.which')
33 @mock.patch('curtin.block.util.subp')
34- def test_check_vtoc_signature_returns_false_with_no_sig(self, mock_subp):
35+ def test_check_vtoc_signature_returns_false_with_no_sig(self, mock_subp,
36+ mock_which):
37+ mock_which.return_value = True
38 mock_subp.side_effect = [
39 util.ProcessExecutionError(stdout="", stderr="", exit_code=1)]
40 self.assertFalse(block.check_vtoc_signature(self.blockdev))
41
42+ @mock.patch('curtin.block.util.which')
43+ @mock.patch('curtin.block.util.subp')
44+ def test_check_vtoc_signature_returns_false_with_no_fdasd(self, mock_subp,
45+ mock_which):
46+ mock_which.return_value = False
47+ self.assertFalse(block.check_vtoc_signature(self.blockdev))
48+
49
50 class TestNonAscii(CiTestCase):
51 @mock.patch('curtin.block.util.subp')

Subscribers

People subscribed via source and target branches