]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd, mds: fix the "heap" admin cmd printing always to error stream 48106/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 17 Aug 2022 12:44:42 +0000 (12:44 +0000)
committerPrashant D <pdhange@redhat.com>
Wed, 14 Sep 2022 23:52:38 +0000 (19:52 -0400)
Before the patch `ceph::osd_cmds::heap()` was confusing
the concepts of _stderr_ and _stdout_. This  was the direct
cause of the differences in output between `ceph tell` and
`ceph daeamon`.

Thanks to Laura Flores who made the extremely useful observation
noted in https://tracker.ceph.com/issues/57119#note-3.

Fixes: https://tracker.ceph.com/issues/57119
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit 94436475c4c9a11a94dd21c619c9ae0014ac393d)

src/mds/MDSDaemon.cc
src/osd/OSD.cc

index 8b653c063f5dabce03a84cc6556328ed65358a5f..4aa4815d1f424095a0222ac72e65ebd37ef0ed75 100644 (file)
@@ -179,7 +179,9 @@ void MDSDaemon::asok_command(
       if (cmd_getval(cmdmap, "value", value)) {
        heapcmd_vec.push_back(value);
       }
-      ceph_heap_profiler_handle_command(heapcmd_vec, ss);
+      std::stringstream outss;
+      ceph_heap_profiler_handle_command(heapcmd_vec, outss);
+      outbl.append(outss);
       r = 0;
     }
   } else if (command == "cpu_profiler") {
index 45470ad8c703482aa23fc4835a34b7e8d8ad2fee..0b8e4b892adb9721d48dc89760ad954836726670 100644 (file)
@@ -2070,7 +2070,10 @@ void OSDService::_queue_for_recovery(
 // Commands shared between OSD's console and admin console:
 namespace ceph::osd_cmds {
 
-int heap(CephContext& cct, const cmdmap_t& cmdmap, Formatter& f, std::ostream& os);
+int heap(CephContext& cct,
+         const cmdmap_t& cmdmap,
+         std::ostream& outos,
+         std::ostream& erros);
 
 } // namespace ceph::osd_cmds
 
@@ -2911,7 +2914,9 @@ will start to track new ops received afterwards.";
   }
 
   else if (prefix == "heap") {
-    ret = ceph::osd_cmds::heap(*cct, cmdmap, *f, ss);
+    std::stringstream outss;
+    ret = ceph::osd_cmds::heap(*cct, cmdmap, outss, ss);
+    outbl.append(outss);
   }
 
   else if (prefix == "debug dump_missing") {
@@ -11318,17 +11323,19 @@ void OSD::ShardedOpWQ::_enqueue_front(OpSchedulerItem&& item)
 
 namespace ceph::osd_cmds {
 
-int heap(CephContext& cct, const cmdmap_t& cmdmap, Formatter& f,
-        std::ostream& os)
+int heap(CephContext& cct,
+         const cmdmap_t& cmdmap,
+         std::ostream& outos,
+         std::ostream& erros)
 {
   if (!ceph_using_tcmalloc()) {
-        os << "could not issue heap profiler command -- not using tcmalloc!";
+        erros << "could not issue heap profiler command -- not using tcmalloc!";
         return -EOPNOTSUPP;
   }
 
   string cmd;
   if (!cmd_getval(cmdmap, "heapcmd", cmd)) {
-        os << "unable to get value for command \"" << cmd << "\"";
+        erros << "unable to get value for command \"" << cmd << "\"";
        return -EINVAL;
   }
 
@@ -11340,7 +11347,7 @@ int heap(CephContext& cct, const cmdmap_t& cmdmap, Formatter& f,
     cmd_vec.push_back(val);
   }
 
-  ceph_heap_profiler_handle_command(cmd_vec, os);
+  ceph_heap_profiler_handle_command(cmd_vec, outos);
 
   return 0;
 }