]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: remove legacy bucket placement and 'radosgw-admin pool' commands
authorCasey Bodley <cbodley@redhat.com>
Wed, 27 Jul 2022 13:27:40 +0000 (09:27 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 6 Nov 2023 16:07:23 +0000 (11:07 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/services/svc_zone.cc
src/rgw/services/svc_zone.h

index 9e6f4c6400084900f8793c5a4bb4caf0b5ccbf65..ced41f87822c79aef1071f2a548b393ad350269c 100644 (file)
@@ -686,9 +686,6 @@ enum class OPT {
   BUCKET_OBJECT_SHARD,
   BUCKET_RESYNC_ENCRYPTED_MULTIPART,
   POLICY,
-  POOL_ADD,
-  POOL_RM,
-  POOLS_LIST,
   LOG_LIST,
   LOG_SHOW,
   LOG_RM,
@@ -910,10 +907,6 @@ static SimpleCmd::Commands all_cmds = {
   { "bucket object shard", OPT::BUCKET_OBJECT_SHARD },
   { "bucket resync encrypted multipart", OPT::BUCKET_RESYNC_ENCRYPTED_MULTIPART },
   { "policy", OPT::POLICY },
-  { "pool add", OPT::POOL_ADD },
-  { "pool rm", OPT::POOL_RM },
-  { "pool list", OPT::POOLS_LIST },
-  { "pools list", OPT::POOLS_LIST },
   { "log list", OPT::LOG_LIST },
   { "log show", OPT::LOG_SHOW },
   { "log rm", OPT::LOG_RM },
@@ -7413,47 +7406,6 @@ next:
     }
   }
 
-  if (opt_cmd == OPT::POOL_ADD) {
-    if (pool_name.empty()) {
-      cerr << "need to specify pool to add!" << std::endl;
-      exit(1);
-    }
-
-    int ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->add_bucket_placement(dpp(), pool, null_yield);
-    if (ret < 0)
-      cerr << "failed to add bucket placement: " << cpp_strerror(-ret) << std::endl;
-  }
-
-  if (opt_cmd == OPT::POOL_RM) {
-    if (pool_name.empty()) {
-      cerr << "need to specify pool to remove!" << std::endl;
-      exit(1);
-    }
-
-    int ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->remove_bucket_placement(dpp(), pool, null_yield);
-    if (ret < 0)
-      cerr << "failed to remove bucket placement: " << cpp_strerror(-ret) << std::endl;
-  }
-
-  if (opt_cmd == OPT::POOLS_LIST) {
-    set<rgw_pool> pools;
-    int ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->list_placement_set(dpp(), pools, null_yield);
-    if (ret < 0) {
-      cerr << "could not list placement set: " << cpp_strerror(-ret) << std::endl;
-      return -ret;
-    }
-    formatter->reset();
-    formatter->open_array_section("pools");
-    for (auto siter = pools.begin(); siter != pools.end(); ++siter) {
-      formatter->open_object_section("pool");
-      formatter->dump_string("name",  siter->to_str());
-      formatter->close_section();
-    }
-    formatter->close_section();
-    formatter->flush(cout);
-    cout << std::endl;
-  }
-
   if (opt_cmd == OPT::USAGE_SHOW) {
     uint64_t start_epoch = 0;
     uint64_t end_epoch = (uint64_t)-1;
index 180d9371222bf490934d6daed12c7d3ab12cd2ff..acf3b5b31cecbb96040a06fa67c18dc6ab2c2b75 100644 (file)
@@ -871,14 +871,7 @@ int RGWSI_Zone::select_new_bucket_location(const DoutPrefixProvider *dpp, const
 int RGWSI_Zone::select_bucket_location_by_rule(const DoutPrefixProvider *dpp, const rgw_placement_rule& location_rule, RGWZonePlacementInfo *rule_info, optional_yield y)
 {
   if (location_rule.name.empty()) {
-    /* we can only reach here if we're trying to set a bucket location from a bucket
-     * created on a different zone, using a legacy / default pool configuration
-     */
-    if (rule_info) {
-      return select_legacy_bucket_placement(dpp, rule_info, y);
-    }
-
-    return 0;
+    return -EINVAL;
   }
 
   /*
@@ -915,164 +908,12 @@ int RGWSI_Zone::select_bucket_placement(const DoutPrefixProvider *dpp, const RGW
                                         rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info,
                                        optional_yield y)
 {
-  if (!zone_params->placement_pools.empty()) {
-    return select_new_bucket_location(dpp, user_info, zonegroup_id, placement_rule,
-                                      pselected_rule, rule_info, y);
-  }
-
-  if (pselected_rule) {
-    pselected_rule->clear();
-  }
-
-  if (rule_info) {
-    return select_legacy_bucket_placement(dpp, rule_info, y);
-  }
-
-  return 0;
-}
-
-int RGWSI_Zone::select_legacy_bucket_placement(const DoutPrefixProvider *dpp, RGWZonePlacementInfo *rule_info,
-                                              optional_yield y)
-{
-  bufferlist map_bl;
-  map<string, bufferlist> m;
-  string pool_name;
-  bool write_map = false;
-
-  rgw_raw_obj obj(zone_params->domain_root, avail_pools);
-
-  auto sysobj = sysobj_svc->get_obj(obj);
-  int ret = sysobj.rop().read(dpp, &map_bl, y);
-  if (ret < 0) {
-    goto read_omap;
-  }
-
-  try {
-    auto iter = map_bl.cbegin();
-    decode(m, iter);
-  } catch (buffer::error& err) {
-    ldpp_dout(dpp, 0) << "ERROR: couldn't decode avail_pools" << dendl;
-  }
-
-read_omap:
-  if (m.empty()) {
-    ret = sysobj.omap().get_all(dpp, &m, y);
-
-    write_map = true;
-  }
-
-  if (ret < 0 || m.empty()) {
-    vector<rgw_pool> pools;
-    string s = string("default.") + default_storage_pool_suffix;
-    pools.push_back(rgw_pool(s));
-    vector<int> retcodes;
-    bufferlist bl;
-    ret = rados_svc->pool().create(dpp, pools, &retcodes);
-    if (ret < 0)
-      return ret;
-    ret = sysobj.omap().set(dpp, s, bl, y);
-    if (ret < 0)
-      return ret;
-    m[s] = bl;
-  }
-
-  if (write_map) {
-    bufferlist new_bl;
-    encode(m, new_bl);
-    ret = sysobj.wop().write(dpp, new_bl, y);
-    if (ret < 0) {
-      ldpp_dout(dpp, 0) << "WARNING: could not save avail pools map info ret=" << ret << dendl;
-    }
-  }
-
-  auto miter = m.begin();
-  if (m.size() > 1) {
-    // choose a pool at random
-    auto r = ceph::util::generate_random_number<size_t>(0, m.size() - 1);
-    std::advance(miter, r);
-  }
-  pool_name = miter->first;
-
-  rgw_pool pool = pool_name;
-
-  rule_info->storage_classes.set_storage_class(RGW_STORAGE_CLASS_STANDARD, &pool, nullptr);
-  rule_info->data_extra_pool = pool_name;
-  rule_info->index_pool = pool_name;
-  rule_info->index_type = rgw::BucketIndexType::Normal;
-
-  return 0;
-}
-
-int RGWSI_Zone::update_placement_map(const DoutPrefixProvider *dpp, optional_yield y)
-{
-  bufferlist header;
-  map<string, bufferlist> m;
-  rgw_raw_obj obj(zone_params->domain_root, avail_pools);
-
-  auto sysobj = sysobj_svc->get_obj(obj);
-  int ret = sysobj.omap().get_all(dpp, &m, y);
-  if (ret < 0)
-    return ret;
-
-  bufferlist new_bl;
-  encode(m, new_bl);
-  ret = sysobj.wop().write(dpp, new_bl, y);
-  if (ret < 0) {
-    ldpp_dout(dpp, 0) << "WARNING: could not save avail pools map info ret=" << ret << dendl;
-  }
-
-  return ret;
-}
-
-int RGWSI_Zone::add_bucket_placement(const DoutPrefixProvider *dpp, const rgw_pool& new_pool, optional_yield y)
-{
-  int ret = rados_svc->pool(new_pool).lookup();
-  if (ret < 0) { // DNE, or something
-    return ret;
-  }
-
-  rgw_raw_obj obj(zone_params->domain_root, avail_pools);
-  auto sysobj = sysobj_svc->get_obj(obj);
-
-  bufferlist empty_bl;
-  ret = sysobj.omap().set(dpp, new_pool.to_str(), empty_bl, y);
-
-  // don't care about return value
-  update_placement_map(dpp, y);
-
-  return ret;
-}
-
-int RGWSI_Zone::remove_bucket_placement(const DoutPrefixProvider *dpp, const rgw_pool& old_pool, optional_yield y)
-{
-  rgw_raw_obj obj(zone_params->domain_root, avail_pools);
-  auto sysobj = sysobj_svc->get_obj(obj);
-  int ret = sysobj.omap().del(dpp, old_pool.to_str(), y);
-
-  // don't care about return value
-  update_placement_map(dpp, y);
-
-  return ret;
-}
-
-int RGWSI_Zone::list_placement_set(const DoutPrefixProvider *dpp, set<rgw_pool>& names, optional_yield y)
-{
-  bufferlist header;
-  map<string, bufferlist> m;
-
-  rgw_raw_obj obj(zone_params->domain_root, avail_pools);
-  auto sysobj = sysobj_svc->get_obj(obj);
-  int ret = sysobj.omap().get_all(dpp, &m, y);
-  if (ret < 0)
-    return ret;
-
-  names.clear();
-  map<string, bufferlist>::iterator miter;
-  for (miter = m.begin(); miter != m.end(); ++miter) {
-    names.insert(rgw_pool(miter->first));
+  if (zone_params->placement_pools.empty()) {
+    return -EINVAL; // legacy placement no longer supported
   }
 
-  return names.size();
+  return select_new_bucket_location(dpp, user_info, zonegroup_id, placement_rule,
+                                    pselected_rule, rule_info, y);
 }
 
 bool RGWSI_Zone::get_redirect_zone_endpoint(string *endpoint)
index 7b0a277c439fd5d6466c8bf7634675e040e18985..3891b73ddb4d8b7418cba77518567247f0b2114f 100644 (file)
@@ -67,8 +67,6 @@ class RGWSI_Zone : public RGWServiceInstance
   int init_zg_from_period(const DoutPrefixProvider *dpp, optional_yield y);
   int init_zg_from_local(const DoutPrefixProvider *dpp, optional_yield y);
 
-  int update_placement_map(const DoutPrefixProvider *dpp, optional_yield y);
-
   int create_default_zg(const DoutPrefixProvider *dpp, optional_yield y);
   int init_default_zone(const DoutPrefixProvider *dpp, optional_yield y);
 
@@ -137,17 +135,12 @@ public:
   int select_bucket_placement(const DoutPrefixProvider *dpp, const RGWUserInfo& user_info, const std::string& zonegroup_id,
                               const rgw_placement_rule& rule,
                               rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info, optional_yield y);
-  int select_legacy_bucket_placement(const DoutPrefixProvider *dpp, RGWZonePlacementInfo *rule_info, optional_yield y);
   int select_new_bucket_location(const DoutPrefixProvider *dpp, const RGWUserInfo& user_info, const std::string& zonegroup_id,
                                  const rgw_placement_rule& rule,
                                  rgw_placement_rule *pselected_rule_name, RGWZonePlacementInfo *rule_info,
                                 optional_yield y);
   int select_bucket_location_by_rule(const DoutPrefixProvider *dpp, const rgw_placement_rule& location_rule, RGWZonePlacementInfo *rule_info, optional_yield y);
 
-  int add_bucket_placement(const DoutPrefixProvider *dpp, const rgw_pool& new_pool, optional_yield y);
-  int remove_bucket_placement(const DoutPrefixProvider *dpp, const rgw_pool& old_pool, optional_yield y);
-  int list_placement_set(const DoutPrefixProvider *dpp, std::set<rgw_pool>& names, optional_yield y);
-
   bool is_meta_master() const;
 
   bool need_to_sync() const;