LVM: Activate LV before creating exports

In some circumstances (such as after a reboot),
especially with thin LVM, the LV may not be activated, so
creating a target from it will fail.

Activate the LV before creating a target.

When using permanent=True for activation, don't supply
the -K/ignoreskipactivation argument.  This is rejected
by LVM 2.02.171, and is not a reasonable request, since
it asks to simultaneously unset a flag, and also to ignore
the flag (which should now be unset) during the same
activation operation.

This fixes a failure to clone a volume from another thin
LVM volume in the same pool.

Closes-Bug: #1701545

Change-Id: I925ece8833cc99a95c4cf693804ca3698f8cb114
This commit is contained in:
Eric Harney 2017-07-19 11:00:41 -04:00
parent 2758720d63
commit 99d79431e3
2 changed files with 6 additions and 1 deletions

View File

@ -676,11 +676,12 @@ class LVM(executor.Executor):
cmd = ['lvchange', '-a', 'y', '--yes']
if self.supports_lvchange_ignoreskipactivation:
cmd.append('-K')
# If permanent=True is specified, drop the skipactivation flag in
# order to make this LV automatically activated after next reboot.
if permanent:
cmd += ['-k', 'n']
else:
cmd.append('-K')
cmd.append(lv_path)

View File

@ -790,6 +790,8 @@ class LVMVolumeDriver(driver.VolumeDriver):
volume_path = "/dev/%s/%s" % (self.configuration.volume_group,
volume['name'])
self.vg.activate_lv(volume['name'])
model_update = \
self.target_driver.ensure_export(context, volume, volume_path)
return model_update
@ -800,6 +802,8 @@ class LVMVolumeDriver(driver.VolumeDriver):
volume_path = "/dev/%s/%s" % (vg, volume['name'])
self.vg.activate_lv(volume['name'])
export_info = self.target_driver.create_export(
context,
volume,