Merge "Shorten snapshots names in CephFS drivers" into stable/zed
This commit is contained in:
commit
91e61299ea
@ -602,7 +602,7 @@ class CephFSDriver(driver.ExecuteMixin, driver.GaneshaMixin,
|
|||||||
argdict = {
|
argdict = {
|
||||||
"vol_name": self.volname,
|
"vol_name": self.volname,
|
||||||
"sub_name": snapshot["share_id"],
|
"sub_name": snapshot["share_id"],
|
||||||
"snap_name": "_".join([snapshot["snapshot_id"], snapshot["id"]]),
|
"snap_name": snapshot["snapshot_id"],
|
||||||
}
|
}
|
||||||
|
|
||||||
rados_command(
|
rados_command(
|
||||||
@ -612,13 +612,24 @@ class CephFSDriver(driver.ExecuteMixin, driver.GaneshaMixin,
|
|||||||
# delete a FS snapshot
|
# delete a FS snapshot
|
||||||
LOG.debug("[%(be)s]: delete_snapshot: snapshot=%(id)s.",
|
LOG.debug("[%(be)s]: delete_snapshot: snapshot=%(id)s.",
|
||||||
{"be": self.backend_name, "id": snapshot['id']})
|
{"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,
|
"vol_name": self.volname,
|
||||||
"sub_name": snapshot["share_id"],
|
"sub_name": snapshot["share_id"],
|
||||||
"snap_name": '_'.join([snapshot['snapshot_id'], snapshot['id']]),
|
"snap_name": legacy_snap_name,
|
||||||
"force": True,
|
"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)
|
rados_command(self.rados_client, "fs subvolume snapshot rm", argdict)
|
||||||
|
|
||||||
def create_share_group(self, context, sg_dict, share_server=None):
|
def create_share_group(self, context, sg_dict, share_server=None):
|
||||||
@ -741,7 +752,7 @@ class CephFSDriver(driver.ExecuteMixin, driver.GaneshaMixin,
|
|||||||
argdict = {
|
argdict = {
|
||||||
"vol_name": self.volname,
|
"vol_name": self.volname,
|
||||||
"sub_name": parent_share["id"],
|
"sub_name": parent_share["id"],
|
||||||
"snap_name": '_'.join([snapshot["snapshot_id"], snapshot["id"]]),
|
"snap_name": snapshot["snapshot_id"],
|
||||||
"target_sub_name": share["id"]
|
"target_sub_name": share["id"]
|
||||||
}
|
}
|
||||||
if share['share_group_id'] is not None:
|
if share['share_group_id'] is not None:
|
||||||
|
@ -367,8 +367,7 @@ class CephFSDriverTestCase(test.TestCase):
|
|||||||
snapshot_create_dict = {
|
snapshot_create_dict = {
|
||||||
"vol_name": self._driver.volname,
|
"vol_name": self._driver.volname,
|
||||||
"sub_name": self._snapshot["share_id"],
|
"sub_name": self._snapshot["share_id"],
|
||||||
"snap_name": "_".join([
|
"snap_name": self._snapshot["snapshot_id"]
|
||||||
self._snapshot["snapshot_id"], self._snapshot["id"]]),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self._driver.create_snapshot(self._context, self._snapshot, None)
|
self._driver.create_snapshot(self._context, self._snapshot, None)
|
||||||
@ -378,23 +377,35 @@ class CephFSDriverTestCase(test.TestCase):
|
|||||||
snapshot_create_prefix, snapshot_create_dict)
|
snapshot_create_prefix, snapshot_create_dict)
|
||||||
|
|
||||||
def test_delete_snapshot(self):
|
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_prefix = "fs subvolume snapshot rm"
|
||||||
|
|
||||||
snapshot_remove_dict = {
|
snapshot_remove_dict = {
|
||||||
"vol_name": self._driver.volname,
|
"vol_name": self._driver.volname,
|
||||||
"sub_name": self._snapshot["share_id"],
|
"sub_name": self._snapshot["share_id"],
|
||||||
"snap_name": "_".join([
|
"snap_name": legacy_snap_name,
|
||||||
self._snapshot["snapshot_id"], self._snapshot["id"]]),
|
"force": True
|
||||||
"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._driver.delete_snapshot(self._context,
|
||||||
self._snapshot,
|
self._snapshot,
|
||||||
None)
|
None)
|
||||||
|
|
||||||
driver.rados_command.assert_called_once_with(
|
driver.rados_command.assert_has_calls([
|
||||||
self._driver.rados_client,
|
mock.call(self._driver.rados_client,
|
||||||
snapshot_remove_prefix, snapshot_remove_dict)
|
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):
|
def test_create_share_group(self):
|
||||||
group_create_prefix = "fs subvolumegroup create"
|
group_create_prefix = "fs subvolumegroup create"
|
||||||
@ -468,8 +479,7 @@ class CephFSDriverTestCase(test.TestCase):
|
|||||||
create_share_from_snapshot_dict = {
|
create_share_from_snapshot_dict = {
|
||||||
"vol_name": self._driver.volname,
|
"vol_name": self._driver.volname,
|
||||||
"sub_name": parent_share["id"],
|
"sub_name": parent_share["id"],
|
||||||
"snap_name": "_".join([
|
"snap_name": self._snapshot["snapshot_id"],
|
||||||
self._snapshot["snapshot_id"], self._snapshot["id"]]),
|
|
||||||
"target_sub_name": self._share["id"]
|
"target_sub_name": self._share["id"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user