Call kpartx remove in umount, not cleanup

Similar to I697bfbf042816c5ddf170bde9534cc4f0c7279ff, the order of
things called is "dib-block-device umount" *then* "dib-block-device
cleanup".

Because we're doing the "kpartx -d" here in cleanup, it means that the
loop-device is removed in umount phase from level0/localloop.py, then
afterwards we try and remove the partitions.

Change-Id: I7af3c5cf66afd81a481f454b5207af552ad52a32
TODO: a test case to ensure the ordering
This commit is contained in:
Ian Wienand 2018-06-28 15:06:58 +10:00
parent a1a549548a
commit f94943344f
2 changed files with 9 additions and 4 deletions

View File

@ -84,5 +84,8 @@ class PartitionNode(NodeBase):
def create(self):
self.partitioning.create()
def umount(self):
self.partitioning.umount()
def cleanup(self):
self.partitioning.cleanup()

View File

@ -215,13 +215,15 @@ class Partitioning(PluginBase):
return
def cleanup(self):
def umount(self):
# remove the partition mappings made for the parent
# block-device by create() above. this is called from the
# child PartitionNode umount/delete/cleanup. Thus every
# partition calls it, but we only want to do it once and our
# gate.
# child PartitionNode umount. Thus every partition calls it,
# but we only want to do it once and our gate.
if not self.already_cleaned:
self.already_cleaned = True
exec_sudo(["kpartx", "-d",
self.state['blockdev'][self.base]['device']])
def cleanup(self):
pass