]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: fix default pool handling for krbd map/unmap
authorIlya Dryomov <idryomov@gmail.com>
Wed, 26 Aug 2020 12:12:29 +0000 (14:12 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 27 Aug 2020 13:53:38 +0000 (15:53 +0200)
The default pool name does not get passed to the kernel since commit
96f05a7956b3 ("rbd: delay determination of default pool name").  The
kernel ends up interpreting the image name as the pool name (and the
snapshot name as the image name).

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

index 40d8d48f939fb97d78e23a05e867d551447af9a0..9d33aa543acd06db58561c0ec8b99ff5050b7910 100644 (file)
@@ -505,15 +505,16 @@ int execute_map(const po::variables_map &vm,
     }
   }
 
+  // connect to the cluster to get the default pool and the default map
+  // options
   librados::Rados rados;
-  librados::IoCtx ioctx;
-  r = utils::init(pool_name, nspace_name, &rados, &ioctx);
+  r = utils::init_rados(&rados);
   if (r < 0) {
     return r;
   }
 
-  // delay processing default options until after global option overrides have
-  // been received
+  utils::normalize_pool_name(&pool_name);
+
   MapOptions default_map_options;
   r = parse_map_options(
       g_conf().get_val<std::string>("rbd_default_map_options"),
@@ -522,7 +523,6 @@ int execute_map(const po::variables_map &vm,
     std::cerr << "rbd: couldn't parse default map options" << std::endl;
     return r;
   }
-
   for (auto& [key, value] : default_map_options) {
     if (map_options.count(key) == 0) {
       map_options[key] = value;
@@ -579,7 +579,16 @@ int execute_unmap(const po::variables_map &vm,
     }
   }
 
-  utils::init_context();
+  if (device_name.empty() && 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);
+  }
 
   r = do_kernel_unmap(device_name.empty() ? nullptr : device_name.c_str(),
                       pool_name.c_str(), nspace_name.c_str(),