fix detection of mounted partitions
Even if we are going to ignore a mountpoint, we still need to process its children... Add machine config where the installer is running from a partition of a disk you might want to install to, and an api test.
This commit is contained in:
parent
e84b3dda8f
commit
b3dafb250b
File diff suppressed because it is too large
Load Diff
|
@ -1292,15 +1292,19 @@ class FilesystemModel(object):
|
||||||
continue
|
continue
|
||||||
majmin_to_dev[f'{major}:{minor}'] = obj
|
majmin_to_dev[f'{major}:{minor}'] = obj
|
||||||
|
|
||||||
|
log.debug("majmin_to_dev %s", majmin_to_dev)
|
||||||
|
|
||||||
mounts = list(self._probe_data.get('mount', []))
|
mounts = list(self._probe_data.get('mount', []))
|
||||||
while mounts:
|
while mounts:
|
||||||
mount = mounts.pop(0)
|
mount = mounts.pop(0)
|
||||||
|
mounts.extend(mount.get('children', []))
|
||||||
if mount['target'].startswith(self.target):
|
if mount['target'].startswith(self.target):
|
||||||
# Completely ignore mounts under /target, they are probably
|
# Completely ignore mounts under /target, they are probably
|
||||||
# leftovers from a previous install attempt.
|
# leftovers from a previous install attempt.
|
||||||
continue
|
continue
|
||||||
if 'maj:min' not in mount:
|
if 'maj:min' not in mount:
|
||||||
continue
|
continue
|
||||||
|
log.debug("considering mount of %s", mount['maj:min'])
|
||||||
obj = majmin_to_dev.get(mount['maj:min'])
|
obj = majmin_to_dev.get(mount['maj:min'])
|
||||||
if obj is None:
|
if obj is None:
|
||||||
continue
|
continue
|
||||||
|
@ -1312,7 +1316,6 @@ class FilesystemModel(object):
|
||||||
if isinstance(o, Disk):
|
if isinstance(o, Disk):
|
||||||
o._has_in_use_partition = True
|
o._has_in_use_partition = True
|
||||||
work.extend(dependencies(o))
|
work.extend(dependencies(o))
|
||||||
mounts.extend(mount.get('children', []))
|
|
||||||
|
|
||||||
# This is a special hack for the install media. When written to a USB
|
# This is a special hack for the install media. When written to a USB
|
||||||
# stick or similar, both the block device for the whole drive and for
|
# stick or similar, both the block device for the whole drive and for
|
||||||
|
|
|
@ -2075,3 +2075,17 @@ class TestActiveDirectory(TestAPI):
|
||||||
# manager will fail to POST /shutdown.
|
# manager will fail to POST /shutdown.
|
||||||
except aiohttp.client_exceptions.ClientOSError:
|
except aiohttp.client_exceptions.ClientOSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestMountDetection(TestAPI):
|
||||||
|
@timeout()
|
||||||
|
async def test_mount_detection(self):
|
||||||
|
# Test that the partition the installer is running from is
|
||||||
|
# correctly identified as mounted.
|
||||||
|
cfg = 'examples/machines/booted-from-rp.json'
|
||||||
|
async with start_server(cfg) as instance:
|
||||||
|
result = await instance.get('/storage/v2')
|
||||||
|
[disk1] = result['disks']
|
||||||
|
self.assertTrue(disk1['has_in_use_partition'])
|
||||||
|
disk1p2 = disk1['partitions'][1]
|
||||||
|
self.assertTrue(disk1p2['is_in_use'])
|
||||||
|
|
Loading…
Reference in New Issue