diff --git a/manila/share/drivers/cephfs/driver.py b/manila/share/drivers/cephfs/driver.py index 37e8935e31..deae78a00e 100644 --- a/manila/share/drivers/cephfs/driver.py +++ b/manila/share/drivers/cephfs/driver.py @@ -595,7 +595,7 @@ class CephFSDriver(driver.ExecuteMixin, driver.GaneshaMixin, argdict = { "vol_name": self.volname, "sub_name": snapshot["share_id"], - "snap_name": "_".join([snapshot["snapshot_id"], snapshot["id"]]), + "snap_name": snapshot["snapshot_id"], } rados_command( @@ -605,13 +605,24 @@ class CephFSDriver(driver.ExecuteMixin, driver.GaneshaMixin, # delete a FS snapshot LOG.debug("[%(be)s]: delete_snapshot: snapshot=%(id)s.", {"be": self.backend_name, "id": snapshot['id']}) - argdict = { + + # FIXME(vkmc) remove this in CC (next tick) release. + legacy_snap_name = "_".join([snapshot["snapshot_id"], snapshot["id"]]) + + argdict_legacy = { "vol_name": self.volname, "sub_name": snapshot["share_id"], - "snap_name": '_'.join([snapshot['snapshot_id'], snapshot['id']]), + "snap_name": legacy_snap_name, "force": True, } + # try removing snapshot using legacy naming + rados_command( + self.rados_client, "fs subvolume snapshot rm", argdict_legacy) + + # in case it's a snapshot with new naming, retry remove with new name + argdict = argdict_legacy.copy() + argdict.update({"snap_name": snapshot["snapshot_id"]}) rados_command(self.rados_client, "fs subvolume snapshot rm", argdict) def create_share_group(self, context, sg_dict, share_server=None): @@ -734,7 +745,7 @@ class CephFSDriver(driver.ExecuteMixin, driver.GaneshaMixin, argdict = { "vol_name": self.volname, "sub_name": parent_share["id"], - "snap_name": '_'.join([snapshot["snapshot_id"], snapshot["id"]]), + "snap_name": snapshot["snapshot_id"], "target_sub_name": share["id"] } if share['share_group_id'] is not None: diff --git a/manila/tests/share/drivers/cephfs/test_driver.py b/manila/tests/share/drivers/cephfs/test_driver.py index 2106aa8e0b..b642624dab 100644 --- a/manila/tests/share/drivers/cephfs/test_driver.py +++ b/manila/tests/share/drivers/cephfs/test_driver.py @@ -364,8 +364,7 @@ class CephFSDriverTestCase(test.TestCase): snapshot_create_dict = { "vol_name": self._driver.volname, "sub_name": self._snapshot["share_id"], - "snap_name": "_".join([ - self._snapshot["snapshot_id"], self._snapshot["id"]]), + "snap_name": self._snapshot["snapshot_id"] } self._driver.create_snapshot(self._context, self._snapshot, None) @@ -375,23 +374,35 @@ class CephFSDriverTestCase(test.TestCase): snapshot_create_prefix, snapshot_create_dict) def test_delete_snapshot(self): + legacy_snap_name = "_".join( + [self._snapshot["snapshot_id"], self._snapshot["id"]]) + snapshot_remove_prefix = "fs subvolume snapshot rm" snapshot_remove_dict = { "vol_name": self._driver.volname, "sub_name": self._snapshot["share_id"], - "snap_name": "_".join([ - self._snapshot["snapshot_id"], self._snapshot["id"]]), - "force": True, + "snap_name": legacy_snap_name, + "force": True } + snapshot_remove_dict_2 = snapshot_remove_dict.copy() + snapshot_remove_dict_2.update( + {"snap_name": self._snapshot["snapshot_id"]}) + self._driver.delete_snapshot(self._context, self._snapshot, None) - driver.rados_command.assert_called_once_with( - self._driver.rados_client, - snapshot_remove_prefix, snapshot_remove_dict) + driver.rados_command.assert_has_calls([ + mock.call(self._driver.rados_client, + snapshot_remove_prefix, + snapshot_remove_dict), + mock.call(self._driver.rados_client, + snapshot_remove_prefix, + snapshot_remove_dict_2)]) + + self.assertEqual(2, driver.rados_command.call_count) def test_create_share_group(self): group_create_prefix = "fs subvolumegroup create" @@ -465,8 +476,7 @@ class CephFSDriverTestCase(test.TestCase): create_share_from_snapshot_dict = { "vol_name": self._driver.volname, "sub_name": parent_share["id"], - "snap_name": "_".join([ - self._snapshot["snapshot_id"], self._snapshot["id"]]), + "snap_name": self._snapshot["snapshot_id"], "target_sub_name": self._share["id"] } diff --git a/releasenotes/notes/bug-1967760-shorten-snapshot-names-cephfs-a220e2b9f7ba5739.yaml b/releasenotes/notes/bug-1967760-shorten-snapshot-names-cephfs-a220e2b9f7ba5739.yaml new file mode 100644 index 0000000000..97287f8b0f --- /dev/null +++ b/releasenotes/notes/bug-1967760-shorten-snapshot-names-cephfs-a220e2b9f7ba5739.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Make snapshot names in CephFS drivers shorter to + avoid limitation in Ceph clusters which truncates + the subvolume name and makes the snapshots inaccesible. \ No newline at end of file