]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks: Compare two FSStatuses
authorJos Collin <jcollin@redhat.com>
Thu, 28 Mar 2019 10:13:49 +0000 (15:43 +0530)
committerJos Collin <jcollin@redhat.com>
Fri, 12 Apr 2019 06:38:42 +0000 (12:08 +0530)
Compare two FSStatuses to detect MDS failover

Fixes: http://tracker.ceph.com/issues/17309
Signed-off-by: Jos Collin <jcollin@redhat.com>
qa/tasks/cephfs/filesystem.py

index a388c769f61fe387f956fa38479c20ddd4f82ec5..3f028dfb7a136912a7a0830bc205b6b23f8e1210 100644 (file)
@@ -140,6 +140,28 @@ class FSStatus(object):
             log.warn(json.dumps(list(self.get_all()), indent=2))  # dump for debugging
             raise RuntimeError("MDS id '{0}' not found in map".format(name))
 
+    def get_mds_gid(self, gid):
+        """
+        Get the info for the given MDS gid.
+        """
+        for info in self.get_all():
+            if info['gid'] == gid:
+                return info
+        return None
+
+    def hadfailover(self, status):
+        """
+        Compares two statuses for mds failovers.
+        Returns True if there is a failover.
+        """
+        for fs in status.map['filesystems']:
+            for info in fs['mdsmap']['info'].values():
+                oldinfo = self.get_mds_gid(info['gid'])
+                if oldinfo is None or oldinfo['incarnation'] != info['incarnation']:
+                    return True
+        #all matching
+        return False
+
 class CephCluster(object):
     @property
     def admin_remote(self):