From 392bc13b5658fc43660a8ebca23b3f433babd882 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 27 Jul 2022 09:27:40 -0400 Subject: [PATCH] rgw: remove legacy bucket placement and 'radosgw-admin pool' commands Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 48 ---------- src/rgw/services/svc_zone.cc | 169 ++--------------------------------- src/rgw/services/svc_zone.h | 7 -- 3 files changed, 5 insertions(+), 219 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 9e6f4c64000..ced41f87822 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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(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(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 pools; - int ret = static_cast(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; diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index 180d9371222..acf3b5b31ce 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -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 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 pools; - string s = string("default.") + default_storage_pool_suffix; - pools.push_back(rgw_pool(s)); - vector 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(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 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& names, optional_yield y) -{ - bufferlist header; - map 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::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) diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index 7b0a277c439..3891b73ddb4 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -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& names, optional_yield y); - bool is_meta_master() const; bool need_to_sync() const; -- 2.39.5