]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs: add sanity check for rados.connect()
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 6 Jun 2016 01:53:33 +0000 (09:53 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 6 Jun 2016 02:19:55 +0000 (10:19 +0800)
Which can fail.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/tools/cephfs/DataScan.cc
src/tools/cephfs/TableTool.cc

index bb0584a365da3a7e14acdb04ff70ea0d93cd6c26..9636696dbe3c6aa16ac85794af41bdc866eb0e6e 100644 (file)
@@ -182,7 +182,12 @@ int DataScan::main(const std::vector<const char*> &args)
     // specialized command that will only exist in the Jewel series,
     // and doesn't require the initialization of the `driver` member
     // that is done below.
-    rados.connect();
+    r = rados.connect();
+    if (r < 0) {
+      std::cerr << "couldn't connect to cluster: " << cpp_strerror(r)
+                << std::endl;
+      return r;
+    }
 
     // Initialize metadata_io from pool on command line
     if (metadata_pool_name.empty()) {
@@ -231,7 +236,13 @@ int DataScan::main(const std::vector<const char*> &args)
   }
 
   dout(4) << "connecting to RADOS..." << dendl;
-  rados.connect();
+  r = rados.connect();
+  if (r < 0) {
+    std::cerr << "couldn't connect to cluster: " << cpp_strerror(r)
+              << std::endl;
+    return r;
+  }
+
   r = driver->init(rados, fsmap, fscid);
   if (r < 0) {
     return r;
index 2ff020a6de6712196169db85490ff568488c90bb..3c4ff8c0718ce0f5eb7b524bdc92139d2a33b74c 100644 (file)
@@ -310,9 +310,11 @@ int TableTool::main(std::vector<const char*> &argv)
   }
 
   dout(4) << "connecting to RADOS..." << dendl;
-  rados.connect();
-
+  r = rados.connect();
+  if (r < 0) {
+    derr << "couldn't connect to cluster: " << cpp_strerror(r) << dendl;
+    return r;
+  }
 
   // Require at least 3 args <rank> <mode> <arg> [args...]
   if (argv.size() < 3) {