]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix default pool handling for nbd/ggate map/unmap
authorSunny Kumar <sunkumar@redhat.com>
Wed, 28 Apr 2021 14:40:30 +0000 (15:40 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 30 Aug 2021 14:32:18 +0000 (16:32 +0200)
Default pool is not being picked up when providing only image name
during map/unmap. However, if the pool name is provided manually map/unmap
works as expected.

Fixes: https://tracker.ceph.com/issues/50522
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
(cherry picked from commit 987e017f20dc419f45f222a35c9ccca79551af7d)

src/tools/rbd/action/Ggate.cc
src/tools/rbd/action/Nbd.cc

index 74cd57dd5a2d0fc7dd0c9eedc0f9972ae2101c28..bae9778bbce9f19a7bffa8667c1236562d839fad 100644 (file)
@@ -65,6 +65,17 @@ int get_image_or_snap_spec(const po::variables_map &vm, std::string *spec) {
     return r;
   }
 
+  if (pool_name.empty()) {
+    // connect to the cluster to get the default pool
+    librados::Rados rados;
+    r = utils::init_rados(&rados);
+    if (r < 0) {
+      return r;
+    }
+
+    utils::normalize_pool_name(&pool_name);
+  }
+
   spec->append(pool_name);
   spec->append("/");
   if (!nspace_name.empty()) {
index bb6ef982920d8dfbd405148d9e59c5444004ee87..5055477b7fe149084541d923d65c1f8cbb32fdb4 100644 (file)
@@ -74,6 +74,17 @@ int get_image_or_snap_spec(const po::variables_map &vm, std::string *spec) {
     return r;
   }
 
+  if (pool_name.empty()) {
+    // connect to the cluster to get the default pool
+    librados::Rados rados;
+    r = utils::init_rados(&rados);
+    if (r < 0) {
+      return r;
+    }
+
+    utils::normalize_pool_name(&pool_name);
+  }
+
   spec->append(pool_name);
   spec->append("/");
   if (!nspace_name.empty()) {