Merge lp:~raharper/curtin/trunk.mount_fs_by_uuid into lp:~curtin-dev/curtin/trunk
- trunk.mount_fs_by_uuid
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 484 |
Proposed branch: | lp:~raharper/curtin/trunk.mount_fs_by_uuid |
Merge into: | lp:~curtin-dev/curtin/trunk |
Diff against target: |
156 lines (+32/-44) 2 files modified
curtin/commands/block_meta.py (+5/-9) tests/vmtests/test_basic.py (+27/-35) |
To merge this branch: | bzr merge lp:~raharper/curtin/trunk.mount_fs_by_uuid |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Scott Moser (community) | Approve | ||
Server Team CI bot | continuous-integration | Approve | |
Review via email: mp+321784@code.launchpad.net |
Commit message
Description of the change
block_meta: Attempt to mount by UUID= if possible
When generating fstab entries in mount_handler prefer UUID if the
underlying volume has an identifiable UUID available.
Update vmtests to check by UUID in test_basic.
Server Team CI bot (server-team-bot) wrote : | # |
Ryan Harper (raharper) wrote : | # |
vmtest run is clean:
https:/
- 485. By Ryan Harper
-
Refine uuid extraction from ls_uuid
- 486. By Ryan Harper
-
merge from trunk
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:486
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Scott Moser (smoser) wrote : | # |
I think this would presumably fix https:/
Scott Moser (smoser) wrote : | # |
i dont think we neeed to block your mp on this, but in general we should be striving to collect generic information in the guest rather than specific little things like 'by_uname' and 'by_dname' and such.
Scott Moser (smoser) wrote : | # |
needs fixing or explanation as to make sure that multipath disks do not get written in /etc/fstab with UUID=. multipath disks need to have mounts done by path to the multipath device (which is consistent thansk to multipath).
Ryan Harper (raharper) wrote : | # |
I think this just works, but follow my logic to confirm.
With this change, the test_multipath vmtest still passes. Here's what the fstab looks like now:
# note those UUID are different, but by only one char (4 vs. 5 a index 7)
(diglett) collect % cat fstab
UUID=b48f7bd4-
UUID=b48f7bd5-
Here is what /dev/disk/by-uuid/ looks like
(diglett) collect % cat ls_uuid
total 0
drwxr-xr-x 2 root root 120 Apr 7 00:12 .
drwxr-xr-x 7 root root 140 Apr 7 00:12 ..
lrwxrwxrwx 1 root root 9 Apr 7 00:12 2017-04-
lrwxrwxrwx 1 root root 10 Apr 7 00:12 b48f7bd4-
lrwxrwxrwx 1 root root 10 Apr 7 00:12 b48f7bd5-
lrwxrwxrwx 1 root root 9 Apr 7 00:12 db8db497-
The UUID points to a device mapper entry
Here's what /dev/disk/by-id shows:
(diglett) collect % cat ls_disk_id
total 0
drwxr-xr-x 2 root root 420 Apr 7 00:12 .
drwxr-xr-x 7 root root 140 Apr 7 00:12 ..
lrwxrwxrwx 1 root root 9 Apr 7 00:12 ata-QEMU_
lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-name-mpath0 -> ../../dm-0
lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-name-
lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-name-
Note that dm-1 and dm-2 are mpath devices.
Below you can see underlying scsi devices that compose the mpath device.
lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-uuid-
lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-uuid-
lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-uuid-
lrwxrwxrwx 1 root root 9 Apr 7 00:12 scsi-0QEMU_
lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-0QEMU_
lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-0QEMU_
lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-0QEMU_
lrwxrwxrwx 1 root root 9 Apr 7 00:12 scsi-1ATA_
lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-mpath0 -> ../../dm-0
lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-mpath0-part1 -> ../../dm-1
lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-mpath0-part2 -> ../../dm-2
lrwxrwxrwx 1 root root 9 Apr 7 00:12 virtio-
lrwxrwxrwx 1 root root 10 Apr 7 00:12 wwn-0xQEMU_
lrwxrwxrwx 1 root root 10 Apr 7 00:12 wwn-0xpath0-part1 -> ../../dm-1
lrwxrwxrwx 1 root root 10 Apr 7 00:12 wwn-0xpath0-part2 -> ../../dm-2
Ryan Harper (raharper) wrote : | # |
After much discussion in #curtin our conclusion
was that, while the risk is small, ideally /etc/fstab should use mpath's
for mpath
devices.
However since the ephemeral environment does not actually configure and
enable multipath; we don't quite know the paths here.
Also, we've been using UUID= mounts for partitions on multipath successfully
since we've supported multipath configurations.
The plan is to continue with using UUID= mounts for bcache and other devices
if a UUID is present and tackle switching to mpath paths for systems with
multipath later.
On Fri, Apr 7, 2017 at 11:05 AM, Ryan Harper <email address hidden>
wrote:
> I think this just works, but follow my logic to confirm.
>
> With this change, the test_multipath vmtest still passes. Here's what the
> fstab looks like now:
>
> # note those UUID are different, but by only one char (4 vs. 5 a index 7)
> (diglett) collect % cat fstab
> UUID=b48f7bd4-
> UUID=b48f7bd5-
>
> Here is what /dev/disk/by-uuid/ looks like
>
> (diglett) collect % cat ls_uuid
> total 0
> drwxr-xr-x 2 root root 120 Apr 7 00:12 .
> drwxr-xr-x 7 root root 140 Apr 7 00:12 ..
> lrwxrwxrwx 1 root root 9 Apr 7 00:12 2017-04-
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 b48f7bd4-
> -> ../../dm-1
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 b48f7bd5-
> -> ../../dm-2
> lrwxrwxrwx 1 root root 9 Apr 7 00:12 db8db497-
> -> ../../vda
>
> The UUID points to a device mapper entry
>
> Here's what /dev/disk/by-id shows:
>
> (diglett) collect % cat ls_disk_id
> total 0
> drwxr-xr-x 2 root root 420 Apr 7 00:12 .
> drwxr-xr-x 7 root root 140 Apr 7 00:12 ..
> lrwxrwxrwx 1 root root 9 Apr 7 00:12 ata-QEMU_
> ../../sr0
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-name-mpath0 -> ../../dm-0
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-name-
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-name-
>
> Note that dm-1 and dm-2 are mpath devices.
>
> Below you can see underlying scsi devices that compose the mpath device.
>
>
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-uuid-
> -> ../../dm-0
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-uuid-
> -> ../../dm-1
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 dm-uuid-
> -> ../../dm-2
> lrwxrwxrwx 1 root root 9 Apr 7 00:12 scsi-0QEMU_
> -> ../../sr0
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-0QEMU_
> -> ../../dm-0
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-0QEMU_
> -> ../../dm-1
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-0QEMU_
> -> ../../dm-2
> lrwxrwxrwx 1 root root 9 Apr 7 00:12 scsi-1ATA_
> ../../sr0
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-mpath0 -> ../../dm-0
> lrwxrwxrwx 1 root root 10 Apr 7 00:12 scsi-mpath0-...
Scott Moser (smoser) : | # |
Preview Diff
1 | === modified file 'curtin/commands/block_meta.py' |
2 | --- curtin/commands/block_meta.py 2017-03-22 21:03:58 +0000 |
3 | +++ curtin/commands/block_meta.py 2017-04-05 20:49:33 +0000 |
4 | @@ -633,15 +633,11 @@ |
5 | # Add volume to fstab |
6 | if state['fstab']: |
7 | with open(state['fstab'], "a") as fp: |
8 | - if volume.get('type') in ["raid", "bcache", |
9 | - "disk", "lvm_partition"]: |
10 | - location = get_path_to_storage_volume(volume.get('id'), |
11 | - storage_config) |
12 | - elif volume.get('type') in ["partition", "dm_crypt"]: |
13 | - location = "UUID=%s" % block.get_volume_uuid(volume_path) |
14 | - else: |
15 | - raise ValueError("cannot write fstab for volume type '%s'" % |
16 | - volume.get("type")) |
17 | + location = get_path_to_storage_volume(volume.get('id'), |
18 | + storage_config) |
19 | + uuid = block.get_volume_uuid(volume_path) |
20 | + if len(uuid) > 0: |
21 | + location = "UUID=%s" % uuid |
22 | |
23 | if filesystem.get('fstype') == "swap": |
24 | path = "none" |
25 | |
26 | === modified file 'tests/vmtests/test_basic.py' |
27 | --- tests/vmtests/test_basic.py 2017-02-22 01:30:50 +0000 |
28 | +++ tests/vmtests/test_basic.py 2017-04-05 20:49:33 +0000 |
29 | @@ -33,6 +33,20 @@ |
30 | echo "$v" > apt-proxy |
31 | """)] |
32 | |
33 | + def _kname_to_uuid(self, kname): |
34 | + # extract uuid from /dev/disk/by-uuid on /dev/<kname> |
35 | + # parsing ls -al output on /dev/disk/by-uuid: |
36 | + # lrwxrwxrwx 1 root root 9 Dec 4 20:02 |
37 | + # d591e9e9-825a-4f0a-b280-3bfaf470b83c -> ../../vdg |
38 | + ls_uuid = self.load_collect_file("ls_uuid") |
39 | + uuid = [line.split()[8] for line in ls_uuid.split('\n') |
40 | + if ("../../" + kname) in line.split()] |
41 | + self.assertEqual(len(uuid), 1) |
42 | + uuid = uuid.pop() |
43 | + self.assertTrue(uuid is not None) |
44 | + self.assertEqual(len(uuid), 36) |
45 | + return uuid |
46 | + |
47 | def test_output_files_exist(self): |
48 | self.output_files_exist( |
49 | ["blkid_output_vda", "blkid_output_vda1", "blkid_output_vda2", |
50 | @@ -79,9 +93,10 @@ |
51 | self.assertEqual(fstab_entry.split(' ')[1], "/home") |
52 | |
53 | # Test whole disk vdd is mounted at /btrfs |
54 | + uuid = self._kname_to_uuid('vdd') |
55 | fstab_entry = None |
56 | for line in fstab_lines: |
57 | - if "/dev/vdd" in line: |
58 | + if uuid in line: |
59 | fstab_entry = line |
60 | break |
61 | self.assertIsNotNone(fstab_entry) |
62 | @@ -90,24 +105,16 @@ |
63 | def test_whole_disk_format(self): |
64 | # confirm the whole disk format is the expected device |
65 | btrfs_uuid = self.load_collect_file('btrfs_uuid_vdd').strip() |
66 | - ls_uuid = self.load_collect_file("ls_uuid") |
67 | |
68 | # extract uuid from btrfs superblock |
69 | self.assertTrue(btrfs_uuid is not None) |
70 | self.assertEqual(len(btrfs_uuid), 36) |
71 | |
72 | - # extract uuid from /dev/disk/by-uuid on /dev/vdd |
73 | - # parsing ls -al output on /dev/disk/by-uuid: |
74 | - # lrwxrwxrwx 1 root root 9 Dec 4 20:02 |
75 | - # d591e9e9-825a-4f0a-b280-3bfaf470b83c -> ../../vdg |
76 | - vdd_uuid = [line.split()[8] for line in ls_uuid.split('\n') |
77 | - if 'vdd' in line] |
78 | - self.assertEqual(len(vdd_uuid), 1) |
79 | - vdd_uuid = vdd_uuid.pop() |
80 | - self.assertTrue(vdd_uuid is not None) |
81 | + # extract uuid from ls_uuid by kname |
82 | + kname_uuid = self._kname_to_uuid('vdd') |
83 | |
84 | # compare them |
85 | - self.assertEqual(vdd_uuid, btrfs_uuid) |
86 | + self.assertEqual(kname_uuid, btrfs_uuid) |
87 | |
88 | def test_proxy_set(self): |
89 | expected = get_apt_proxy() |
90 | @@ -153,23 +160,15 @@ |
91 | def test_whole_disk_format(self): |
92 | # confirm the whole disk format is the expected device |
93 | btrfs_uuid = self.load_collect_file("btrfs_uuid_vdd").strip() |
94 | - ls_uuid = self.load_collect_file("ls_uuid") |
95 | |
96 | self.assertTrue(btrfs_uuid is not None) |
97 | self.assertEqual(len(btrfs_uuid), 36) |
98 | |
99 | - # extract uuid from /dev/disk/by-uuid on /dev/vdd |
100 | - # parsing ls -al output on /dev/disk/by-uuid: |
101 | - # lrwxrwxrwx 1 root root 9 Dec 4 20:02 |
102 | - # d591e9e9-825a-4f0a-b280-3bfaf470b83c -> ../../vdg |
103 | - vdd_uuid = [line.split()[8] for line in ls_uuid.split('\n') |
104 | - if 'vdd' in line] |
105 | - self.assertEqual(len(vdd_uuid), 1) |
106 | - vdd_uuid = vdd_uuid.pop() |
107 | - self.assertTrue(vdd_uuid is not None) |
108 | + # extract uuid from ls_uuid by kname |
109 | + kname_uuid = self._kname_to_uuid('vdd') |
110 | |
111 | # compare them |
112 | - self.assertEqual(vdd_uuid, btrfs_uuid) |
113 | + self.assertEqual(kname_uuid, btrfs_uuid) |
114 | |
115 | def test_ptable(self): |
116 | print("test_ptable does not work for Precise") |
117 | @@ -289,9 +288,10 @@ |
118 | self.assertEqual(fstab_entry.split(' ')[1], "/home") |
119 | |
120 | # Test whole disk sdc is mounted at /btrfs |
121 | + uuid = self._kname_to_uuid('sdc') |
122 | fstab_entry = None |
123 | for line in fstab_lines: |
124 | - if "/dev/sdc" in line: |
125 | + if uuid in line: |
126 | fstab_entry = line |
127 | break |
128 | self.assertIsNotNone(fstab_entry) |
129 | @@ -300,24 +300,16 @@ |
130 | def test_whole_disk_format(self): |
131 | # confirm the whole disk format is the expected device |
132 | btrfs_uuid = self.load_collect_file("btrfs_uuid_sdc").strip() |
133 | - ls_uuid = self.load_collect_file("ls_uuid") |
134 | |
135 | # extract uuid from btrfs superblock |
136 | self.assertTrue(btrfs_uuid is not None) |
137 | self.assertEqual(len(btrfs_uuid), 36) |
138 | |
139 | - # extract uuid from /dev/disk/by-uuid on /dev/sdc |
140 | - # parsing ls -al output on /dev/disk/by-uuid: |
141 | - # lrwxrwxrwx 1 root root 9 Dec 4 20:02 |
142 | - # d591e9e9-825a-4f0a-b280-3bfaf470b83c -> ../../vdg |
143 | - uuid = [line.split()[8] for line in ls_uuid.split('\n') |
144 | - if 'sdc' in line] |
145 | - self.assertEqual(len(uuid), 1) |
146 | - uuid = uuid.pop() |
147 | - self.assertTrue(uuid is not None) |
148 | + # extract uuid from ls_uuid by kname |
149 | + kname_uuid = self._kname_to_uuid('sdc') |
150 | |
151 | # compare them |
152 | - self.assertEqual(uuid, btrfs_uuid) |
153 | + self.assertEqual(kname_uuid, btrfs_uuid) |
154 | |
155 | |
156 | class XenialTestScsiBasic(relbase.xenial, TestBasicScsiAbs): |
PASSED: Continuous integration, rev:484 /jenkins. ubuntu. com/server/ job/curtin- ci/432/ /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-amd64/ 432 /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-arm64/ 432 /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-ppc64el/ 432 /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-s390x/ 432 /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= vm-i386/ 432
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/curtin- ci/432/ rebuild
https:/