]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: return 0 and an empty list when pool is entirely empty 1028/head
authorJosh Durgin <josh.durgin@inktank.com>
Wed, 1 Jan 2014 01:00:06 +0000 (17:00 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Wed, 1 Jan 2014 01:02:28 +0000 (17:02 -0800)
rbd_list will return -ENOENT when no rbd_directory object
exists. Handle this in the cli tool and interpret it as success with
an empty list.

Add this to the release notes since it changes command line behavior.

Fixes: #6693
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
PendingReleaseNotes
src/rbd.cc
src/test/cli-integration/rbd/formatted-output.t

index 0c39dbb96a38be58f4a450ac6f97584412d1b05f..65b4f1ab7400b0a56fefd87fa697fa0e3e0a74bf 100644 (file)
@@ -1,3 +1,12 @@
+v0.75
+~~~~~
+
+- 'rbd ls' on a pool which never held rbd images now exits with code
+  0. It outputs nothing in plain format, or an empty list in
+  non-plain format. This is consistent with the behavior for a pool
+  which used to hold images, but contains none. Scripts relying on
+  this behavior should be updated.
+
 v0.74
 ~~~~~
 
index 1cc792f2be01f386378139ce619a0277bc3106ea..5143c306b4f9753db70d9e4279e8d9800b622d8e 100644 (file)
@@ -251,6 +251,8 @@ static int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool lflag,
 {
   std::vector<string> names;
   int r = rbd.list(io_ctx, names);
+  if (r == -ENOENT)
+    r = 0;
   if (r < 0)
     return r;
 
@@ -2777,14 +2779,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \
   case OPT_LIST:
     r = do_list(rbd, io_ctx, lflag, formatter.get());
     if (r < 0) {
-      switch (r) {
-      case -ENOENT:
-        cerr << "rbd: pool " << poolname << " doesn't contain rbd images"
-            << std::endl;
-        break;
-      default:
-        cerr << "rbd: list: " << cpp_strerror(-r) << std::endl;
-      }
+      cerr << "rbd: list: " << cpp_strerror(-r) << std::endl;
       return -r;
     }
     break;
index 707e07493679dafe8caf420b3745b59d2ab2fb74..666b12612db71f6779dee718ac467f5feaa14018 100644 (file)
@@ -1,3 +1,12 @@
+ls on empty pool never containing images
+========================================
+  $ rados -p rbd rm rbd_directory || true
+  $ rbd ls
+  $ rbd ls --format json
+  [] (no-eol)
+  $ rbd ls --format xml
+  <images></images> (no-eol)
+
 create
 =======
   $ rbd create -s 1024 foo