From 1a5f08154d903412e7a516647ed8123ce2c652cf Mon Sep 17 00:00:00 2001 From: Yaguang Tang Date: Fri, 6 Dec 2024 16:58:02 +0800 Subject: [PATCH] fix manila share mount use device name issue --- ...e-device-uuid-instead-of-name-for-mo.patch | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 images/manila/patches/0001-fix-manila-to-use-device-uuid-instead-of-name-for-mo.patch diff --git a/images/manila/patches/0001-fix-manila-to-use-device-uuid-instead-of-name-for-mo.patch b/images/manila/patches/0001-fix-manila-to-use-device-uuid-instead-of-name-for-mo.patch new file mode 100644 index 000000000..c561e51e7 --- /dev/null +++ b/images/manila/patches/0001-fix-manila-to-use-device-uuid-instead-of-name-for-mo.patch @@ -0,0 +1,54 @@ +From 6c401bff32e4dc82e26d31081285df528921aff0 Mon Sep 17 00:00:00 2001 +From: Yaguang Tang +Date: Thu, 5 Dec 2024 23:43:11 +0800 +Subject: [PATCH] fix manila to use device uuid instead of name for mounting + +Closes-bug: #2091102 + +Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b +--- + manila/share/drivers/generic.py | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/manila/share/drivers/generic.py b/manila/share/drivers/generic.py +index d7f08a058..140d8dc7c 100644 +--- a/manila/share/drivers/generic.py ++++ b/manila/share/drivers/generic.py +@@ -286,7 +286,7 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver): + return True + return False + +- def _add_mount_permanently(self, share_id, server_details): ++ def _add_mount_permanently(self, share_id, device_path, server_details): + """Add mount permanently for mounted filesystems.""" + try: + self._ssh_exec( +@@ -294,6 +294,16 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver): + ['grep', share_id, const.MOUNT_FILE_TEMP, + '|', 'sudo', 'tee', '-a', const.MOUNT_FILE], + ) ++ output, __ = self._ssh_exec( ++ server_details, ++ ['lsblk', '-o', 'uuid', '-n', device_path]) ++ if output: ++ device_uuid = f"UUID={output.strip()}" ++ self._ssh_exec( ++ server_details, ++ ['sudo', 'sed', '-i', "s@{}@{}@".format(device_path, ++ device_uuid), const.MOUNT_FILE] ++ ) + except exception.ProcessExecutionError as e: + LOG.error("Failed to add 'Share-%(share_id)s' mount " + "permanently on server '%(instance_id)s'.", +@@ -363,7 +373,7 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver): + '&&', 'sudo', 'mount', device_path, mount_path, + ) + self._ssh_exec(server_details, mount_cmd) +- self._add_mount_permanently(share.id, server_details) ++ self._add_mount_permanently(share.id, device_path, server_details) + else: + LOG.warning("Mount point '%(path)s' already exists on " + "server '%(server)s'.", log_data) +-- +2.39.5 (Apple Git-154) +