Skip to content

Commit 69704e9

Browse files
committed
Merge PR ceph#53301 into main
* refs/pull/53301/head: qa: adding test for preventing scrub when mds is inactive mds: prevent scrub start for standby-replay MDS Reviewed-by: Dhairya Parmar <[email protected]> Reviewed-by: Venky Shankar <[email protected]> Reviewed-by: Milind Changire <[email protected]>
2 parents 08d7ff9 + b9a2d05 commit 69704e9

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

qa/tasks/cephfs/test_scrub_checks.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,40 @@ def promoted():
176176

177177
self._check_task_status_na()
178178

179+
def test_scrub_when_mds_is_inactive(self):
180+
test_dir = "scrub_control_test_path"
181+
abs_test_path = f"/{test_dir}"
182+
183+
self.create_scrub_data(test_dir)
184+
185+
# allow standby-replay
186+
self.fs.set_max_mds(1)
187+
self.fs.set_allow_standby_replay(True)
188+
status = self.fs.wait_for_daemons()
189+
sr_mds_id = self.fs.get_daemon_names('up:standby-replay', status=status)[0]
190+
191+
# start the scrub and verify
192+
with self.assertRaises(CommandFailedError) as ce:
193+
self.run_ceph_cmd('tell', f'mds.{sr_mds_id}', 'scrub',
194+
'start', abs_test_path, 'recursive')
195+
self.assertEqual(ce.exception.exitstatus, errno.EINVAL)
196+
197+
# pause and verify
198+
with self.assertRaises(CommandFailedError) as ce:
199+
self.run_ceph_cmd('tell', f'mds.{sr_mds_id}', 'scrub', 'pause')
200+
self.assertEqual(ce.exception.exitstatus, errno.EINVAL)
201+
202+
# abort and verify
203+
with self.assertRaises(CommandFailedError) as ce:
204+
self.run_ceph_cmd('tell', f'mds.{sr_mds_id}', 'scrub', 'abort')
205+
self.assertEqual(ce.exception.exitstatus, errno.EINVAL)
206+
207+
# resume and verify
208+
with self.assertRaises(CommandFailedError) as ce:
209+
self.run_ceph_cmd('tell', f'mds.{sr_mds_id}', 'scrub', 'resume')
210+
self.assertEqual(ce.exception.exitstatus, errno.EINVAL)
211+
212+
179213
class TestScrubChecks(CephFSTestCase):
180214
"""
181215
Run flush and scrub commands on the specified files in the filesystem. This

src/mds/MDSRank.cc

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,7 +2880,12 @@ void MDSRankDispatcher::handle_asok_command(
28802880
r = config_client(client_id, !got_value, option, value, *css);
28812881
} else if (command == "scrub start" ||
28822882
command == "scrub_start") {
2883-
if (whoami != 0) {
2883+
if (!is_active()) {
2884+
*css << "MDS is not active";
2885+
r = -CEPHFS_EINVAL;
2886+
goto out;
2887+
}
2888+
else if (whoami != 0) {
28842889
*css << "Not rank 0";
28852890
r = -CEPHFS_EXDEV;
28862891
goto out;
@@ -2906,7 +2911,12 @@ void MDSRankDispatcher::handle_asok_command(
29062911
}));
29072912
return;
29082913
} else if (command == "scrub abort") {
2909-
if (whoami != 0) {
2914+
if (!is_active()) {
2915+
*css << "MDS is not active";
2916+
r = -CEPHFS_EINVAL;
2917+
goto out;
2918+
}
2919+
else if (whoami != 0) {
29102920
*css << "Not rank 0";
29112921
r = -CEPHFS_EXDEV;
29122922
goto out;
@@ -2921,7 +2931,12 @@ void MDSRankDispatcher::handle_asok_command(
29212931
}));
29222932
return;
29232933
} else if (command == "scrub pause") {
2924-
if (whoami != 0) {
2934+
if (!is_active()) {
2935+
*css << "MDS is not active";
2936+
r = -CEPHFS_EINVAL;
2937+
goto out;
2938+
}
2939+
else if (whoami != 0) {
29252940
*css << "Not rank 0";
29262941
r = -CEPHFS_EXDEV;
29272942
goto out;
@@ -2936,7 +2951,12 @@ void MDSRankDispatcher::handle_asok_command(
29362951
}));
29372952
return;
29382953
} else if (command == "scrub resume") {
2939-
if (whoami != 0) {
2954+
if (!is_active()) {
2955+
*css << "MDS is not active";
2956+
r = -CEPHFS_EINVAL;
2957+
goto out;
2958+
}
2959+
else if (whoami != 0) {
29402960
*css << "Not rank 0";
29412961
r = -CEPHFS_EXDEV;
29422962
goto out;

0 commit comments

Comments
 (0)