]> git.apps.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)
committerMatt Benjamin <mbenjamin@redhat.com>
Sun, 17 Jul 2022 22:37:37 +0000 (18:37 -0400)
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>
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_motr.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h

index f7d9f7cfa90d5edc2e4ffe7ca981e59f82914726..8125b4ab8efd06c8a153923926f4848efae6a6e3 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;
 }
@@ -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<std::tuple<LCOpRule, rgw_bucket_dir_entry>>(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():" <<dendl;
+      ldpp_dout(this, 0) << "ERROR: store->list_objects():" << dendl;
       return ret;
     }
 
index 42f061d7a31023f4bcd58025aea2ffe1bdfb0b98..3daa6e1aade0451913a3ca5c37738dc71aa9788d 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 fdfbb26b3fde17b83d86fa929b77798a392dd5f4..b2542772a6df29daa5ef8b850db9d0ea4a37d4ff 100644 (file)
@@ -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;
 };
 
 /**
index d076c4ce9c8a15cfca01ae33e5ca82c43a93e176..5258e760d96e598c99999d6e2ec1f1a6b67791d4 100644 (file)
@@ -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 {
index f90eb6d9890014fd24c2a16fb5a04e796f72c935..33db3598325d360c12b2c5ca69a59ddff96b8df1 100644 (file)
@@ -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;
 };
 
index c09d5de458b4a652ed901dbf7550b021b9aa760d..22ae73d3a63ca87009ec91eb96b769c83c4602e9 100644 (file)
@@ -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;
index 388145e3078dbfcedf61398d59f7abc8ed4498d9..693c0569b7e0d13004c7505c30f21f5a7dfad284 100644 (file)
@@ -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 {