]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Revert "Merge PR #19369 into master"
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 4 Jan 2018 17:41:06 +0000 (09:41 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 4 Jan 2018 17:42:37 +0000 (09:42 -0800)
This reverts commit 3189ba19a779e4a54265aa831a57d686a7911187, reversing
changes made to b7620de0200bdbac6a1a7abbdfbafd8b43d7bf47.

Despite the change in json format being positive, the unfortunate side-effect
is that it broke upgrade testing (because the QA framework must handle the
transition of mdsmap["info"] to a list from object) and the ceph-mgr.

Fixes: http://tracker.ceph.com/issues/22527
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
.githubmap
PendingReleaseNotes
qa/tasks/cephfs/filesystem.py
qa/tasks/cephfs/test_failover.py
qa/tasks/cephfs/test_strays.py
src/mds/MDSMap.cc
src/pybind/ceph_volume_client.py

index d2e4d3c894afe3eee25ea736cc6b45f629757449..bee2e2a3605950d39b80ad13dd1be75880cbafe4 100644 (file)
@@ -51,4 +51,3 @@ jtlayton Jeff Layton <jlayton@redhat.com>
 yuriw Yuri Weinstein <yweins@redhat.com>
 jecluis João Eduardo Luís <joao@suse.de>
 yunfeiguan Yunfei Guan <yunfei.guan@xtaotech.com>
-xiaoxichen Xiaoxi Chen <xiaoxchen@ebay.com>
index f5b945d8df35cff0b4cad3908792f51790c25e8b..b48eb44cf70ba1cbc4adfe5be207e27253b34e2e 100644 (file)
@@ -25,8 +25,7 @@
     mds_session_timeout, mds_session_autoclose, and mds_max_file_size are now
     obsolete.
 
-  * The JSON format of `ceph fs status` and `ceph mds stat` has changed
-    for the "up" and "info" sections of the mds_map.
+
 
 >= 12.2.2
 ---------
index c94d80bf4ab62d16f9f7c6fa191f51f0d0a21927..d7fa5168c005c53c43a0ef5490c6e62a3b453264 100644 (file)
@@ -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']:
+            for info in fs['mdsmap']['info'].values():
                 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']:
+        for info in fs['mdsmap']['info'].values():
             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']:
+        for info in fs['mdsmap']['info'].values():
             if info['rank'] >= 0:
                 yield info
 
@@ -119,14 +119,6 @@ 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.
@@ -302,8 +294,8 @@ class MDSCluster(CephCluster):
             mdsmap = fs['mdsmap']
             metadata_pool = pool_id_name[mdsmap['metadata_pool']]
 
-            for info in status.get_ranks(fs['id']):
-                self.mon_manager.raw_cluster_cmd('mds', 'fail', str(info['gid']))
+            for gid in mdsmap['up'].values():
+                self.mon_manager.raw_cluster_cmd('mds', 'fail', gid.__str__())
 
             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',
@@ -670,11 +662,11 @@ class Filesystem(MDSCluster):
 
         log.info("are_daemons_healthy: mds map: {0}".format(mds_map))
 
-        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']))
+        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']))
                 return False
-            elif info['state'] == 'up:active':
+            elif mds_status['state'] == 'up:active':
                 active_count += 1
 
         log.info("are_daemons_healthy: {0}/{1}".format(
@@ -683,10 +675,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 info in mds_map['info']:
-                if info['state'] == 'up:active':
+            for mds_id, mds_status in mds_map['info'].items():
+                if mds_status['state'] == 'up:active':
                     try:
-                        daemon_status = self.mds_asok(["status"], mds_id=info['name'])
+                        daemon_status = self.mds_asok(["status"], mds_id=mds_status['name'])
                     except CommandFailedError as cfe:
                         if cfe.exitstatus == errno.EINVAL:
                             # Old version, can't do this check
@@ -711,7 +703,7 @@ class Filesystem(MDSCluster):
         """
         status = self.get_mds_map()
         result = []
-        for mds_status in sorted(status['info'], lambda a, b: cmp(a['rank'], b['rank'])):
+        for mds_status in sorted(status['info'].values(), lambda a, b: cmp(a['rank'], b['rank'])):
             if mds_status['state'] == state or state is None:
                 result.append(mds_status['name'])
 
@@ -729,7 +721,7 @@ class Filesystem(MDSCluster):
     def get_all_mds_rank(self):
         status = self.get_mds_map()
         result = []
-        for mds_status in sorted(status['info'], lambda a, b: cmp(a['rank'], b['rank'])):
+        for mds_status in sorted(status['info'].values(), 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'])
 
@@ -744,7 +736,7 @@ class Filesystem(MDSCluster):
         """
         status = self.get_mds_map()
         result = []
-        for mds_status in sorted(status['info'], lambda a, b: cmp(a['rank'], b['rank'])):
+        for mds_status in sorted(status['info'].values(), 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'])
 
index 1ece40fcc6e3705b36417f687fa1e21e9cf146f8..3306e9441c712a8462230a4c21e7db11ff5ed93a 100644 (file)
@@ -83,7 +83,8 @@ class TestFailover(CephFSTestCase):
 
         # Wait for everyone to go laggy
         def laggy():
-            for info in self.fs.status().get_cluster(self.fs.id):
+            mdsmap = self.fs.get_mds_map()
+            for info in mdsmap['info'].values():
                 if "laggy_since" not in info:
                     return False
 
@@ -468,7 +469,7 @@ class TestMultiFilesystems(CephFSTestCase):
 
         def get_info_by_name(fs, mds_name):
             mds_map = fs.get_mds_map()
-            for info in mds_map['info']:
+            for gid_str, info in mds_map['info'].items():
                 if info['name'] == mds_name:
                     return info
 
index 5483d51bf245beccbac26813f9eb3dca6f77d575..919b059b871ebf45de1a8a02c053b67277951cfb 100644 (file)
@@ -544,7 +544,8 @@ class TestStrays(CephFSTestCase):
                     time.sleep(1)
 
     def _is_stopped(self, rank):
-        return rank not in self.fs.get_mds_map()['up']
+        mds_map = self.fs.get_mds_map()
+        return rank not in [i['rank'] for i in mds_map['info'].values()]
 
     def test_purge_on_shutdown(self):
         """
index 7678635e53421c8d22f87b9e0aaa6ab316d91598..ea154ff18bb9be6a2596f95ded191c7f6af50c70 100644 (file)
@@ -153,9 +153,11 @@ void MDSMap::dump(Formatter *f) const
   for (set<mds_rank_t>::const_iterator p = in.begin(); p != in.end(); ++p)
     f->dump_int("mds", *p);
   f->close_section();
-  f->open_array_section("up");
+  f->open_object_section("up");
   for (map<mds_rank_t,mds_gid_t>::const_iterator p = up.begin(); p != up.end(); ++p) {
-    f->dump_int("mds", p->first);
+    char s[14];
+    sprintf(s, "mds_%d", int(p->first));
+    f->dump_int(s, p->second);
   }
   f->close_section();
   f->open_array_section("failed");
@@ -170,9 +172,11 @@ void MDSMap::dump(Formatter *f) const
   for (set<mds_rank_t>::const_iterator p = stopped.begin(); p != stopped.end(); ++p)
     f->dump_int("mds", *p);
   f->close_section();
-  f->open_array_section("info");
+  f->open_object_section("info");
   for (map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin(); p != mds_info.end(); ++p) {
-    f->open_object_section("info_item");
+    char s[25]; // 'gid_' + len(str(ULLONG_MAX)) + '\0'
+    sprintf(s, "gid_%llu", (long long unsigned)p->first);
+    f->open_object_section(s);
     p->second.dump(f);
     f->close_section();
   }
index ae6bb8327d166222b191ebb351e2883a4de88932..9e4a2a21682dfdc84a322a532cfbe70f67192a78 100644 (file)
@@ -114,21 +114,14 @@ class RankEvicter(threading.Thread):
 
         super(RankEvicter, self).__init__()
 
-    def _get_info(self, key, value):
-        for info in self._mds_map["info"]:
-            if info[key] == value:
-                return info
-        return {}
-
     def _ready_to_evict(self):
-        info = self._get_info('rank', self.rank)
-        if (self.rank not in self._mds_map['up']) or info.get('gid', None) != self.gid:
+        if self._mds_map['up'].get("mds_{0}".format(self.rank), None) != self.gid:
             log.info("Evicting {0} from {1}/{2}: rank no longer associated with gid, done.".format(
                 self._client_spec, self.rank, self.gid
             ))
             raise RankEvicter.GidGone()
 
-        info = self._get_info('gid', self.gid)
+        info = self._mds_map['info']["gid_{0}".format(self.gid)]
         log.debug("_ready_to_evict: state={0}".format(info['state']))
         return info['state'] in ["up:active", "up:clientreplay"]
 
@@ -400,8 +393,10 @@ class CephFSVolumeClient(object):
 
         mds_map = self.get_mds_map()
         up = {}
-        for rank in mds_map['up']:
-            up[rank] = self._get_info('rank', rank)['gid']
+        for name, gid in mds_map['up'].items():
+            # Quirk of the MDSMap JSON dump: keys in the up dict are like "mds_0"
+            assert name.startswith("mds_")
+            up[int(name[4:])] = gid
 
         # For all MDS ranks held by a daemon
         # Do the parallelism in python instead of using "tell mds.*", because