From 0bcb9102174e5d1279fbc507acb161160a366dff Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Wed, 26 May 2021 14:21:22 +0200 Subject: [PATCH] rbd: combined error message for expected Trash::purge() errors Output to stderr instead of the log where regular users wouldn't see it given the elevated log level. Signed-off-by: Ilya Dryomov --- src/librbd/api/Trash.cc | 20 -------------------- src/tools/rbd/action/Trash.cc | 9 +++++++++ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/librbd/api/Trash.cc b/src/librbd/api/Trash.cc index 485290b499b..e4e7bd87da3 100644 --- a/src/librbd/api/Trash.cc +++ b/src/librbd/api/Trash.cc @@ -532,26 +532,6 @@ int Trash::purge(IoCtx& io_ctx, time_t expire_ts, for (const auto &entry_id : to_be_removed) { r = librbd::api::Trash::remove(io_ctx, entry_id, true, remove_pctx); if (r < 0) { - if (r == -ENOTEMPTY) { - ldout(cct, 5) << "image has snapshots - these must be deleted " - << "with 'rbd snap purge' before the image can be " - << "removed." << dendl; - } else if (r == -EBUSY) { - ldout(cct, 5) << "error: image still has watchers" << std::endl - << "This means the image is still open or the client " - << "using it crashed. Try again after closing/unmapping " - << "it or waiting 30s for the crashed client to timeout." - << dendl; - } else if (r == -EUCLEAN) { - ldout(cct, 5) << "Image is not in the expected state. Ensure moving " - << "the image to the trash completed successfully." - << dendl; - } else if (r == -EMLINK) { - ldout(cct, 5) << "Remove the image from the group and try again." - << dendl; - } else { - lderr(cct) << "remove error: " << cpp_strerror(r) << dendl; - } return r; } pctx.update_progress(++i, list_size); diff --git a/src/tools/rbd/action/Trash.cc b/src/tools/rbd/action/Trash.cc index ba09c6406df..05cc724589b 100644 --- a/src/tools/rbd/action/Trash.cc +++ b/src/tools/rbd/action/Trash.cc @@ -446,6 +446,15 @@ int execute_purge(const po::variables_map &vm, r = rbd.trash_purge_with_progress(io_ctx, expire_ts, threshold, pc); if (r < 0) { pc.fail(); + if (r == -ENOTEMPTY || r == -EBUSY || r == -EMLINK || r == -EUCLEAN) { + std::cerr << "rbd: some expired images could not be removed" + << std::endl + << "Ensure that they are closed/unmapped, do not have " + << "snapshots (including trashed snapshots with linked " + << "clones), are not in a group and were moved to the " + << "trash successfully." + << std::endl; + } return r; } -- 2.39.5