Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd: return 0 and an empty list when pool is entirely empty #1028

Merged
merged 1 commit into from
Jan 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions PendingReleaseNotes
Original file line number Diff line number Diff line change
@@ -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
~~~~~

Expand Down
11 changes: 3 additions & 8 deletions src/rbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/test/cli-integration/rbd/formatted-output.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down