From 1f1a2a27efc0e3a99a07b36fc2cf20b2bd270b8b Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 19 Dec 2017 16:12:28 -0800 Subject: [PATCH] qa: update handling of fs status format Signed-off-by: Patrick Donnelly --- qa/tasks/cephfs/filesystem.py | 38 +++++++++++++++++++------------- qa/tasks/cephfs/test_failover.py | 5 ++--- qa/tasks/cephfs/test_strays.py | 3 +-- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index fce7931696fd..5cccbc861319 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -64,7 +64,7 @@ class FSStatus(object): for info in self.get_standbys(): yield info for fs in self.map['filesystems']: - for info in fs['mdsmap']['info'].values(): + for info in fs['mdsmap']['info']: yield info def get_standbys(self): @@ -97,7 +97,7 @@ class FSStatus(object): Get the standby:replay MDS for the given FSCID. """ fs = self.get_fsmap(fscid) - for info in fs['mdsmap']['info'].values(): + for info in fs['mdsmap']['info']: if info['state'] == 'up:standby-replay': yield info @@ -106,7 +106,7 @@ class FSStatus(object): Get the ranks for the given FSCID. """ fs = self.get_fsmap(fscid) - for info in fs['mdsmap']['info'].values(): + for info in fs['mdsmap']['info']: if info['rank'] >= 0: yield info @@ -119,6 +119,14 @@ class FSStatus(object): return info raise RuntimeError("FSCID {0} has no rank {1}".format(fscid, rank)) + def get_cluster(self, fscid): + """ + Get the MDS cluster for the given FSCID. + """ + fs = self.get_fsmap(fscid) + for info in fs['mdsmap']['info']: + yield info + def get_mds(self, name): """ Get the info for the given MDS name. @@ -294,8 +302,8 @@ class MDSCluster(CephCluster): mdsmap = fs['mdsmap'] metadata_pool = pool_id_name[mdsmap['metadata_pool']] - for gid in mdsmap['up'].values(): - self.mon_manager.raw_cluster_cmd('mds', 'fail', gid.__str__()) + for info in status.get_ranks(fs['id']): + self.mon_manager.raw_cluster_cmd('mds', 'fail', str(info['gid'])) self.mon_manager.raw_cluster_cmd('fs', 'rm', mdsmap['fs_name'], '--yes-i-really-mean-it') self.mon_manager.raw_cluster_cmd('osd', 'pool', 'delete', @@ -659,11 +667,11 @@ class Filesystem(MDSCluster): log.info("are_daemons_healthy: mds map: {0}".format(mds_map)) - for mds_id, mds_status in mds_map['info'].items(): - if mds_status['state'] not in ["up:active", "up:standby", "up:standby-replay"]: - log.warning("Unhealthy mds state {0}:{1}".format(mds_id, mds_status['state'])) + for info in mds_map['info']: + if info['state'] not in ["up:active", "up:standby", "up:standby-replay"]: + log.warning("Unhealthy mds state {0}:{1}".format(info['gid'], info['state'])) return False - elif mds_status['state'] == 'up:active': + elif info['state'] == 'up:active': active_count += 1 log.info("are_daemons_healthy: {0}/{1}".format( @@ -672,10 +680,10 @@ class Filesystem(MDSCluster): if active_count >= mds_map['max_mds']: # The MDSMap says these guys are active, but let's check they really are - for mds_id, mds_status in mds_map['info'].items(): - if mds_status['state'] == 'up:active': + for info in mds_map['info']: + if info['state'] == 'up:active': try: - daemon_status = self.mds_asok(["status"], mds_id=mds_status['name']) + daemon_status = self.mds_asok(["status"], mds_id=info['name']) except CommandFailedError as cfe: if cfe.exitstatus == errno.EINVAL: # Old version, can't do this check @@ -700,7 +708,7 @@ class Filesystem(MDSCluster): """ status = self.get_mds_map() result = [] - for mds_status in sorted(status['info'].values(), lambda a, b: cmp(a['rank'], b['rank'])): + for mds_status in sorted(status['info'], lambda a, b: cmp(a['rank'], b['rank'])): if mds_status['state'] == state or state is None: result.append(mds_status['name']) @@ -718,7 +726,7 @@ class Filesystem(MDSCluster): def get_all_mds_rank(self): status = self.get_mds_map() result = [] - for mds_status in sorted(status['info'].values(), lambda a, b: cmp(a['rank'], b['rank'])): + for mds_status in sorted(status['info'], lambda a, b: cmp(a['rank'], b['rank'])): if mds_status['rank'] != -1 and mds_status['state'] != 'up:standby-replay': result.append(mds_status['rank']) @@ -733,7 +741,7 @@ class Filesystem(MDSCluster): """ status = self.get_mds_map() result = [] - for mds_status in sorted(status['info'].values(), lambda a, b: cmp(a['rank'], b['rank'])): + for mds_status in sorted(status['info'], lambda a, b: cmp(a['rank'], b['rank'])): if mds_status['rank'] != -1 and mds_status['state'] != 'up:standby-replay': result.append(mds_status['name']) diff --git a/qa/tasks/cephfs/test_failover.py b/qa/tasks/cephfs/test_failover.py index 3306e9441c71..1ece40fcc6e3 100644 --- a/qa/tasks/cephfs/test_failover.py +++ b/qa/tasks/cephfs/test_failover.py @@ -83,8 +83,7 @@ class TestFailover(CephFSTestCase): # Wait for everyone to go laggy def laggy(): - mdsmap = self.fs.get_mds_map() - for info in mdsmap['info'].values(): + for info in self.fs.status().get_cluster(self.fs.id): if "laggy_since" not in info: return False @@ -469,7 +468,7 @@ class TestMultiFilesystems(CephFSTestCase): def get_info_by_name(fs, mds_name): mds_map = fs.get_mds_map() - for gid_str, info in mds_map['info'].items(): + for info in mds_map['info']: if info['name'] == mds_name: return info diff --git a/qa/tasks/cephfs/test_strays.py b/qa/tasks/cephfs/test_strays.py index 3c2a86993f2d..2c1d4c682499 100644 --- a/qa/tasks/cephfs/test_strays.py +++ b/qa/tasks/cephfs/test_strays.py @@ -544,8 +544,7 @@ class TestStrays(CephFSTestCase): time.sleep(1) def _is_stopped(self, rank): - mds_map = self.fs.get_mds_map() - return rank not in [i['rank'] for i in mds_map['info'].values()] + return rank not in self.fs.get_mds_map()['up'] def test_purge_on_shutdown(self): """ -- 2.47.3