From ace8fb7609db6cf6bf09eee288cbee63c8fa23ae 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 (cherry picked from commit 98c598bde777d8cc1892a99287f9e22cd211a8e8) Conflicts: src/rgw/rgw_sal.h (trivial) src/rgw/rgw_sal_dbstore.h (trivial) src/rgw/rgw_sal_motr.h (not exist) src/rgw/rgw_sal_rados.cc (trivial) src/rgw/rgw_sal_rados.h (trivial) --- 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_rados.cc | 5 +++++ src/rgw/rgw_sal_rados.h | 1 + 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index d9960e06468..a3f349ce0d2 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; } @@ -976,7 +976,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, RGWObjectCtx& ctx, bufferlist& tags_bl) { @@ -996,6 +996,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) { @@ -1769,6 +1779,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); @@ -1821,11 +1834,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 15abbedaca7..d7967145648 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 7eb6abd5f55..b3bdd98fa1d 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -1423,6 +1423,8 @@ class Zone { virtual bool has_zonegroup_api(const std::string& api) const = 0; /** Get the current period ID for this zone */ virtual const std::string& get_current_period_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 4f67c422ba4..e42615d5ef2 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -270,6 +270,7 @@ protected: virtual bool get_redirect_endpoint(std::string* endpoint) override; virtual bool has_zonegroup_api(const std::string& api) const override; virtual const std::string& get_current_period_id() override; + virtual const std::string& get_tier_type() override { return "fixme"; } }; class DBLuaScriptManager : public LuaScriptManager { diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 0a18c299223..b6b1416d1f7 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -2817,6 +2817,11 @@ const std::string& RadosZone::get_current_period_id() return store->svc()->zone->get_current_period_id(); } +const std::string& RadosZone::get_tier_type() +{ + return store->svc()->zone->get_zone().tier_type; +} + int RadosLuaScriptManager::get(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script) { auto obj_ctx = store->svc()->sysobj->init_obj_ctx(); diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index cbae743bd06..37bc2baf9a6 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -358,6 +358,7 @@ class RadosZone : public Zone { virtual bool get_redirect_endpoint(std::string* endpoint) override; virtual bool has_zonegroup_api(const std::string& api) const override; virtual const std::string& get_current_period_id() override; + virtual const std::string& get_tier_type() override; }; class RadosStore : public Store { -- 2.47.3