]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados: check return values for commands that can now fail
authorJosh Durgin <josh.durgin@inktank.com>
Thu, 6 Feb 2014 01:25:24 +0000 (17:25 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Tue, 11 Feb 2014 00:02:44 +0000 (16:02 -0800)
A few places were not checking the return values of commands, since
they could not fail before timeouts were added.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
(cherry picked from commit 79c1874346ff55e2dc74ef860db16ce70242fd00)

src/tools/rados/rados.cc

index ad8eaa3e1a4a2563acd0dbc03730993a6696b9d6..443f90207d7c1ea808da6182323cb9b5117dd0eb 100644 (file)
@@ -1260,7 +1260,11 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   // list pools?
   if (strcmp(nargs[0], "lspools") == 0) {
     list<string> vec;
-    rados.pool_list(vec);
+    ret = rados.pool_list(vec);
+    if (ret < 0) {
+      cerr << "error listing pools: " << cpp_strerror(ret) << std::endl;
+      goto out;
+    }
     for (list<string>::iterator i = vec.begin(); i != vec.end(); ++i)
       cout << *i << std::endl;
   }
@@ -1268,13 +1272,22 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
     // pools
     list<string> vec;
 
-    if (!pool_name)
-      rados.pool_list(vec);
-    else
+    if (!pool_name) {
+      ret = rados.pool_list(vec);
+      if (ret < 0) {
+       cerr << "error listing pools: " << cpp_strerror(ret) << std::endl;
+       goto out;
+      }
+    } else {
       vec.push_back(pool_name);
+    }
 
     map<string, map<string, pool_stat_t> > stats;
-    rados.get_pool_stats(vec, category, stats);
+    ret = rados.get_pool_stats(vec, category, stats);
+    if (ret < 0) {
+      cerr << "error fetching pool stats: " << cpp_strerror(ret) << std::endl;
+      goto out;
+    }
 
     if (!formatter) {
       printf("%-15s %-15s"
@@ -1351,7 +1364,11 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
 
     // total
     cluster_stat_t tstats;
-    rados.cluster_stat(tstats);
+    ret = rados.cluster_stat(tstats);
+    if (ret < 0) {
+      cerr << "error getting total cluster usage: " << cpp_strerror(ret) << std::endl;
+      goto out;
+    }
     if (!formatter) {
       printf("  total used    %12lld %12lld\n", (long long unsigned)tstats.kb_used,
             (long long unsigned)tstats.num_objects);