From 1ff77095fd13bce945786e35dada63b20560679b Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 11 Mar 2021 10:31:05 -0800 Subject: [PATCH] qa: remove get_lone_mds_id This helps remove a dependence on the list of mds_daemons from teuthology/cephadm. Signed-off-by: Patrick Donnelly (cherry picked from commit 8e45af05c9933312f5b739b79e87fa2cf33a043a) --- qa/tasks/cephfs/filesystem.py | 19 ++----------------- qa/tasks/cephfs/test_admin.py | 6 ++---- qa/tasks/cephfs/test_misc.py | 11 ++++------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 3c07a99edcf09..cd60e6ebef4ad 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -1036,21 +1036,6 @@ class Filesystem(MDSCluster): status = self.status() - def get_lone_mds_id(self): - """ - Get a single MDS ID: the only one if there is only one - configured, else the only one currently holding a rank, - else raise an error. - """ - if len(self.mds_ids) != 1: - alive = self.get_rank_names() - if len(alive) == 1: - return alive[0] - else: - raise ValueError("Explicit MDS argument required when multiple MDSs in use") - else: - return self.mds_ids[0] - def put_metadata_object_raw(self, object_id, infile): """ Save an object to the metadata pool @@ -1113,13 +1098,13 @@ class Filesystem(MDSCluster): def mds_asok(self, command, mds_id=None, timeout=None): if mds_id is None: - mds_id = self.get_lone_mds_id() + return self.rank_asok(command, timeout=timeout) return self.json_asok(command, 'mds', mds_id, timeout=timeout) def mds_tell(self, command, mds_id=None): if mds_id is None: - mds_id = self.get_lone_mds_id() + return self.rank_tell(command) return json.loads(self.mon_manager.raw_cluster_cmd("tell", f"mds.{mds_id}", *command)) diff --git a/qa/tasks/cephfs/test_admin.py b/qa/tasks/cephfs/test_admin.py index 408744ae63b04..c10b9a482e02d 100644 --- a/qa/tasks/cephfs/test_admin.py +++ b/qa/tasks/cephfs/test_admin.py @@ -314,12 +314,10 @@ class TestConfigCommands(CephFSTestCase): test_key = "mds_max_purge_ops" test_val = "123" - mds_id = self.fs.get_lone_mds_id() - self.fs.mon_manager.raw_cluster_cmd("tell", "mds.{0}".format(mds_id), "injectargs", - "--{0}={1}".format(test_key, test_val)) + self.fs.rank_tell(['injectargs', "--{0}={1}".format(test_key, test_val)]) # Read it back with asok because there is no `tell` equivalent - out = self.fs.mds_asok(['config', 'get', test_key]) + out = self.fs.rank_tell(['config', 'get', test_key]) self.assertEqual(out[test_key], test_val) diff --git a/qa/tasks/cephfs/test_misc.py b/qa/tasks/cephfs/test_misc.py index b8740136067aa..a0169bef8f4ec 100644 --- a/qa/tasks/cephfs/test_misc.py +++ b/qa/tasks/cephfs/test_misc.py @@ -204,14 +204,11 @@ class TestCacheDrop(CephFSTestCase): def _run_drop_cache_cmd(self, timeout=None): result = None - mds_id = self.fs.get_lone_mds_id() + args = ["cache", "drop"] if timeout is not None: - result = self.fs.mon_manager.raw_cluster_cmd("tell", "mds.{0}".format(mds_id), - "cache", "drop", str(timeout)) - else: - result = self.fs.mon_manager.raw_cluster_cmd("tell", "mds.{0}".format(mds_id), - "cache", "drop") - return json.loads(result) + args.append(str(timeout)) + result = self.fs.rank_tell(args) + return result def _setup(self, max_caps=20, threshold=400): # create some files -- 2.39.5