]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: combined error message for expected Trash::purge() errors
authorIlya Dryomov <idryomov@gmail.com>
Wed, 26 May 2021 12:21:22 +0000 (14:21 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 31 May 2021 09:44:47 +0000 (11:44 +0200)
Output to stderr instead of the log where regular users wouldn't see
it given the elevated log level.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/api/Trash.cc
src/tools/rbd/action/Trash.cc

index 485290b499b1f0213bf05109a2ae8a6659d7df8c..e4e7bd87da3b8d25e622705deb9012ebabba41aa 100644 (file)
@@ -532,26 +532,6 @@ int Trash<I>::purge(IoCtx& io_ctx, time_t expire_ts,
   for (const auto &entry_id : to_be_removed) {
     r = librbd::api::Trash<I>::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);
index ba09c6406df8ece5cb703ab7f9767f894ea2a501..05cc724589b374c4a7595bc532b0d87d4c60e95d 100644 (file)
@@ -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;
   }