From 98c598bde777d8cc1892a99287f9e22cd211a8e8 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Fri, 1 Jul 2022 17:55:33 -0400 Subject: [PATCH] rgwlc: zone-conditional lifecycle processing Lifecycle rules with the ArchiveZone flag must execute on archive zones, but must not execute on others. Fixes: https://tracker.ceph.com/issues/56440 Signed-off-by: Matt Benjamin --- src/rgw/rgw_lc.cc | 25 ++++++++++++++++++++++--- src/rgw/rgw_lc.h | 3 ++- src/rgw/rgw_sal.h | 2 ++ src/rgw/rgw_sal_dbstore.h | 1 + src/rgw/rgw_sal_motr.h | 2 +- src/rgw/rgw_sal_rados.cc | 5 +++++ src/rgw/rgw_sal_rados.h | 1 + 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index f7d9f7cfa90d5..8125b4ab8efd0 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -151,10 +151,10 @@ bool RGWLifecycleConfiguration::_add_rule(const LCRule& rule) } else { prefix = rule.get_prefix(); } - if (rule.get_filter().has_tags()){ op.obj_tags = rule.get_filter().get_tags(); } + op.rule_flags = rule.get_filter().get_flags(); prefix_map.emplace(std::move(prefix), std::move(op)); return true; } @@ -911,7 +911,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, worker->workpool->drain(); return 0; -} +} /* RGWLC::handle_multipart_expiration */ static int read_obj_tags(const DoutPrefixProvider *dpp, rgw::sal::Object* obj, bufferlist& tags_bl) { @@ -931,6 +931,16 @@ static bool is_valid_op(const lc_op& op) || !op.noncur_transitions.empty())); } +static bool zone_check(const lc_op& op, rgw::sal::Zone* zone) +{ + + if (zone->get_tier_type() == "archive") { + return (op.rule_flags & uint32_t(LCFlagType::ArchiveZone)); + } else { + return (! (op.rule_flags & uint32_t(LCFlagType::ArchiveZone))); + } +} + static inline bool has_all_tags(const lc_op& rule_action, const RGWObjTags& object_tags) { @@ -1573,6 +1583,9 @@ int RGWLC::bucket_lc_process(string& shard_id, LCWorker* worker, return -1; } + /* fetch information for zone checks */ + rgw::sal::Zone* zone = store->get_zone(); + auto pf = [](RGWLC::LCWorker* wk, WorkQ* wq, WorkItem& wi) { auto wt = boost::get>(wi); @@ -1625,11 +1638,17 @@ int RGWLC::bucket_lc_process(string& shard_id, LCWorker* worker, LCObjsLister ol(store, bucket.get()); ol.set_prefix(prefix_iter->first); + if (! zone_check(op, zone)) { + ldpp_dout(this, 7) << "LC rule not executable in " << zone->get_tier_type() + << " zone, skipping" << dendl; + continue; + } + ret = ol.init(this); if (ret < 0) { if (ret == (-ENOENT)) return 0; - ldpp_dout(this, 0) << "ERROR: store->list_objects():" <list_objects():" << dendl; return ret; } diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 42f061d7a3102..3daa6e1aade04 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -213,7 +213,7 @@ public: return obj_tags; } - const uint32_t get_flags() { + const uint32_t get_flags() const { return flags; } @@ -438,6 +438,7 @@ struct lc_op boost::optional obj_tags; std::map transitions; std::map noncur_transitions; + uint32_t rule_flags; /* ctors are nice */ lc_op() = delete; diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index fdfbb26b3fde1..b2542772a6df2 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -1495,6 +1495,8 @@ class Zone { virtual const std::string& get_realm_name() = 0; /** Get the ID of the realm containing this zone */ virtual const std::string& get_realm_id() = 0; + /** Get the tier type for the zone */ + virtual const std::string& get_tier_type() = 0; }; /** diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index d076c4ce9c8a1..5258e760d96e5 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -335,6 +335,7 @@ protected: virtual const RGWAccessKey& get_system_key() override; virtual const std::string& get_realm_name() override; virtual const std::string& get_realm_id() override; + virtual const std::string& get_tier_type() override { return "fixme"; } }; class DBLuaScriptManager : public StoreLuaScriptManager { diff --git a/src/rgw/rgw_sal_motr.h b/src/rgw/rgw_sal_motr.h index f90eb6d989001..33db3598325d3 100644 --- a/src/rgw/rgw_sal_motr.h +++ b/src/rgw/rgw_sal_motr.h @@ -457,7 +457,7 @@ class MotrZone : public StoreZone { virtual const RGWAccessKey& get_system_key() { return zone_params->system_key; } virtual const std::string& get_realm_name() { return realm->get_name(); } virtual const std::string& get_realm_id() { return realm->get_id(); } - + virtual const std::string& get_tier_type() { return "fixme"; } friend class MotrStore; }; diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index c09d5de458b4a..22ae73d3a63ca 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -3008,6 +3008,11 @@ const std::string& RadosZone::get_realm_id() return store->svc()->zone->get_realm().get_id(); } +const std::string& RadosZone::get_tier_type() +{ + return store->svc()->zone->get_zone().tier_type; +} + RadosLuaScriptManager::RadosLuaScriptManager(RadosStore* _s) : store(_s) { pool = store->svc()->zone->get_zone_params().log_pool; diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index 388145e3078db..693c0569b7e0d 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -107,6 +107,7 @@ class RadosZone : public StoreZone { virtual const RGWAccessKey& get_system_key() override; virtual const std::string& get_realm_name() override; virtual const std::string& get_realm_id() override; + virtual const std::string& get_tier_type() override; }; class RadosStore : public StoreStore { -- 2.39.5