Skip to content

Commit

Permalink
qa: update handling of fs status format
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Donnelly <[email protected]>
  • Loading branch information
batrick committed Dec 21, 2017
1 parent 25d9473 commit 1f1a2a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
38 changes: 23 additions & 15 deletions qa/tasks/cephfs/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_all(self):
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):
Expand Down Expand Up @@ -97,7 +97,7 @@ def get_replays(self, fscid):
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

Expand All @@ -106,7 +106,7 @@ def get_ranks(self, fscid):
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

Expand All @@ -119,6 +119,14 @@ def get_rank(self, fscid, rank):
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.
Expand Down Expand Up @@ -294,8 +302,8 @@ def delete_all_filesystems(self):
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',
Expand Down Expand Up @@ -659,11 +667,11 @@ def are_daemons_healthy(self):

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(
Expand All @@ -672,10 +680,10 @@ def are_daemons_healthy(self):

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
Expand All @@ -700,7 +708,7 @@ def get_daemon_names(self, state=None):
"""
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'])

Expand All @@ -718,7 +726,7 @@ def get_active_names(self):
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'])

Expand All @@ -733,7 +741,7 @@ def get_rank_names(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['name'])

Expand Down
5 changes: 2 additions & 3 deletions qa/tasks/cephfs/test_failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def test_client_abort(self):

# 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

Expand Down Expand Up @@ -469,7 +468,7 @@ def set_standby_for(leader, follower, replay):

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

Expand Down
3 changes: 1 addition & 2 deletions qa/tasks/cephfs/test_strays.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,7 @@ def _force_migrate(self, to_id, path, watch_ino):
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):
"""
Expand Down

0 comments on commit 1f1a2a2

Please sign in to comment.