]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc: zone-conditional lifecycle processing
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 1 Jul 2022 21:55:33 +0000 (17:55 -0400)
committerMykola Golub <mgolub@suse.com>
Tue, 12 Dec 2023 10:14:07 +0000 (12:14 +0200)
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 <mbenjamin@redhat.com>
(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
src/rgw/rgw_lc.h
src/rgw/rgw_sal.h
src/rgw/rgw_sal_dbstore.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h

index d9960e064688814a5eb3c2fa9783b79332c95170..a3f349ce0d28567fc6bbb7e252d12789f9999f04 100644 (file)
@@ -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<std::tuple<LCOpRule, rgw_bucket_dir_entry>>(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():" <<dendl;
+      ldpp_dout(this, 0) << "ERROR: store->list_objects():" << dendl;
       return ret;
     }
 
index 15abbedaca77da2b79469127ecbe96da7809a576..d796714564831f6ddde90463cd64188eb500eb1f 100644 (file)
@@ -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<RGWObjTags> obj_tags;
   std::map<std::string, transition_action> transitions;
   std::map<std::string, transition_action> noncur_transitions;
+  uint32_t rule_flags;
 
   /* ctors are nice */
   lc_op() = delete;
index 7eb6abd5f5591d74879c1107898b4ed91aaf6102..b3bdd98fa1d7c3a55e2fbc45f57a65343dc65c81 100644 (file)
@@ -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;
 };
 
 /**
index 4f67c422ba4b528e66ac80674e18a19d93785008..e42615d5ef21603245d5c4f58e843ded1828e9c1 100644 (file)
@@ -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 {
index 0a18c299223015dfb1215e8012035a7b1c7edb14..b6b1416d1f73e384169dae76bf80996a99a2fff7 100644 (file)
@@ -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();
index cbae743bd06e7cc2a46df6540a5f8b8cb665c58c..37bc2baf9a6c1e71d54d79f791c479461e5fd79d 100644 (file)
@@ -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 {