mgr: don't write to output if EOPNOTSUPP 25317/head
authorKefu Chai <kchai@redhat.com>
Thu, 29 Nov 2018 07:44:55 +0000 (15:44 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 29 Nov 2018 07:45:37 +0000 (15:45 +0800)
if process_pg_map_command() fails to fulfill the request, we should keep
the odata intact. and let the module take care of it.

before this change, we always write to odata even if
process_pg_map_command() returns -EOPNOTSUPP, this leaves unnecessary
leftover in the output, like pg_info,pg_ready.

after this change, we won't touch odata if process_pg_map_command()
returns -EOPNOTSUPP. and odata will be filled with whatever the python
module returns.

Fixes: http://tracker.ceph.com/issues/37444
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/DaemonServer.cc

index 4069715e8b7944a429296fab0d587a78742530af..eea7503caf26f9a5c55c4f38d3b3020bb4ea7f74 100644 (file)
@@ -2050,9 +2050,11 @@ bool DaemonServer::_handle_command(
 
     if (f) {
       f->close_section();
-      f->flush(cmdctx->odata);
     }
     if (r != -EOPNOTSUPP) {
+      if (f) {
+       f->flush(cmdctx->odata);
+      }
       cmdctx->reply(r, ss);
       return true;
     }