From 1bfbfc3a7a0e84aa2a0f7afffe2985f132f5d341 Mon Sep 17 00:00:00 2001 From: Chen Date: Mon, 22 Oct 2018 17:56:13 +0800 Subject: [PATCH] lvm backup: calculate path_to_backup after volume is mounted For the time being, the path_to_backup for backup with lvm snapshot is not taken directly from --path-to-backup parameter, but adjusted according the mount info of the corresponding volume hinted by that parameter. However this info is inferred before the volume is actually mounted so it tends to be inaccuate and leads to errors. So do the calculation after volume mounting instead. Change-Id: I0d7f3125520aa27ba1d2d94ff52e3cc0eea4916c Closes-Bug: #1799183 Story: 2004152 Task: 27623 --- freezer/snapshot/lvm.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/freezer/snapshot/lvm.py b/freezer/snapshot/lvm.py index e0575173..74e2cdcd 100644 --- a/freezer/snapshot/lvm.py +++ b/freezer/snapshot/lvm.py @@ -115,9 +115,6 @@ def lvm_snap(backup_opt_dict): "{0}/mount_{1}".format(freezer_config.DEFAULT_LVM_MOUNT_BASEDIR, lvm_uuid) - backup_opt_dict.path_to_backup = os.path.join(backup_opt_dict.lvm_dirmount, - lvm_info['snap_path']) - if not validate_lvm_params(backup_opt_dict): LOG.info('No LVM requested/configured') return False @@ -186,6 +183,12 @@ def lvm_snap(backup_opt_dict): 'Volume {0} successfully mounted on {1}'.format( abs_snap_name, backup_opt_dict.lvm_dirmount)) + # After snapshot is mounted, adjust path_to_backup according the mount + # point and relative path of the snapshot volume. + lvm_info = get_lvm_info(backup_opt_dict.path_to_backup) + backup_opt_dict.path_to_backup = os.path.join(backup_opt_dict.lvm_dirmount, + lvm_info['snap_path']) + return True