Skip to content

Commit 485717a

Browse files
authored
Merge pull request ceph#57388 from mchangir/mgr-snap_schedule-correctly-fetch-mds_max_snaps_per_dir-from-mds
mgr/snap_schedule: correctly fetch mds_max_snaps_per_dir from mds Reviewed-by: Venky Shankar <[email protected]>
2 parents e541e99 + 1fda7cb commit 485717a

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

qa/tasks/cephfs/test_snap_schedules.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,56 @@ def test_snap_dir_name(self):
10931093
self.mount_a.run_shell(['rmdir', TestSnapSchedulesSnapdir.TEST_DIRECTORY])
10941094

10951095

1096+
class TestSnapSchedulesFetchForeignConfig(TestSnapSchedulesHelper):
1097+
def test_fetch_for_mds_max_snaps_per_dir(self):
1098+
"""Test the correctness of snap directory name"""
1099+
dir_path = TestSnapSchedulesHelper.TEST_DIRECTORY
1100+
sdn = self.get_snap_dir_name()
1101+
1102+
self.mount_a.run_shell(['mkdir', '-p', dir_path])
1103+
1104+
# set a schedule on the dir
1105+
self.fs_snap_schedule_cmd('add', path=dir_path, snap_schedule='1m')
1106+
1107+
self.config_set('mds', 'mds_max_snaps_per_dir', 10)
1108+
1109+
time.sleep(11*60) # wait for 9 snaps to be retained
1110+
1111+
snap_path = f"{dir_path}/{sdn}"
1112+
snapshots = self.mount_a.ls(path=snap_path)
1113+
fs_count = len(snapshots)
1114+
1115+
self.assertTrue(fs_count == 9)
1116+
1117+
self.config_set('mds', 'mds_max_snaps_per_dir', 8)
1118+
1119+
time.sleep(1*60 + 10) # wait for max_snaps_per_dir limit to be breached
1120+
1121+
snap_path = f"{dir_path}/{sdn}"
1122+
snapshots = self.mount_a.ls(path=snap_path)
1123+
fs_count = len(snapshots)
1124+
1125+
self.assertTrue(fs_count == 7)
1126+
1127+
self.config_set('mds', 'mds_max_snaps_per_dir', 10)
1128+
1129+
time.sleep(2*60 + 10) # wait for more snaps to be created
1130+
1131+
snap_path = f"{dir_path}/{sdn}"
1132+
snapshots = self.mount_a.ls(path=snap_path)
1133+
fs_count = len(snapshots)
1134+
1135+
self.assertTrue(fs_count == 9)
1136+
1137+
# remove snapshot schedule
1138+
self.fs_snap_schedule_cmd('remove', path=dir_path)
1139+
1140+
# remove all scheduled snapshots
1141+
self.remove_snapshots(dir_path, sdn)
1142+
1143+
self.mount_a.run_shell(['rmdir', dir_path])
1144+
1145+
10961146
"""
10971147
Note that the class TestSnapSchedulesMandatoryFSArgument tests snap-schedule
10981148
commands only for multi-fs scenario. Commands for a single default fs should

src/pybind/mgr/snap_schedule/fs/schedule_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def prune_snapshots(self, sched: Schedule) -> None:
361361
path = sched.path
362362
prune_candidates = set()
363363
time = datetime.now(timezone.utc)
364-
mds_max_snaps_per_dir = self.mgr.get_ceph_option('mds_max_snaps_per_dir')
364+
mds_max_snaps_per_dir = self.mgr.get_foreign_ceph_option('mds', 'mds_max_snaps_per_dir')
365365
with open_filesystem(self, sched.fs) as fs_handle:
366366
snap_dir = self.mgr.rados.conf_get('client_snapdir')
367367
with fs_handle.opendir(f'{path}/{snap_dir}') as d_handle:

0 commit comments

Comments
 (0)