status = self.fs.status()
max_mds = status.get_fsmap(self.fs.id)['mdsmap']['max_mds']
ranks = list(status.get_ranks(self.fs.id))
- stopping = filter(lambda info: "up:stopping" == info['state'], ranks)
- actives = filter(lambda info: "up:active" == info['state'] and "laggy_since" not in info, ranks)
+ stopping = sum(1 for _ in ranks if "up:stopping" == _['state'])
+ actives = sum(1 for _ in ranks
+ if "up:active" == _['state'] and "laggy_since" not in _)
- if not bool(self.config.get('thrash_while_stopping', False)) and len(stopping) > 0:
+ if not bool(self.config.get('thrash_while_stopping', False)) and stopping > 0:
if itercount % 5 == 0:
self.log('cluster is considered unstable while MDS are in up:stopping (!thrash_while_stopping)')
else:
return status
except:
pass # no rank present
- if len(actives) >= max_mds:
+ if actives >= max_mds:
# no replacement can occur!
- self.log("cluster has %d actives (max_mds is %d), no MDS can replace rank %d".format(len(actives), max_mds, rank))
+ self.log("cluster has {actives} actives (max_mds is {max_mds}), no MDS can replace rank {rank}".format(
+ actives=actives, max_mds=max_mds, rank=rank))
return status
else:
- if len(actives) == max_mds:
- self.log('mds cluster has {count} alive and active, now stable!'.format(count = len(actives)))
+ if actives == max_mds:
+ self.log('mds cluster has {count} alive and active, now stable!'.format(count = actives))
return status, None
if itercount > 300/2: # 5 minutes
raise RuntimeError('timeout waiting for cluster to stabilize')