Merge "Shorten snapshots names in CephFS drivers" into stable/xena

This commit is contained in:
Zuul 2024-01-12 15:43:10 +00:00 committed by Gerrit Code Review
commit 55822d312a
3 changed files with 41 additions and 14 deletions

View File

@ -580,7 +580,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(
@ -590,13 +590,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):
@ -719,7 +730,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:

View File

@ -352,8 +352,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)
@ -363,23 +362,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"
@ -453,8 +464,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"]
}

View File

@ -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.