]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc: faithfully store lifecycle filters 69117/head
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 27 May 2026 04:14:17 +0000 (00:14 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 4 Jun 2026 14:31:34 +0000 (10:31 -0400)
Fix the bug where an empty lifecycle filter was stored
identically to one with an empty old-format prefix rule--
which caused the recovered rules to be formed incorrectly
as prefix rules.

Found by Kyle Bader and Tekton workflow.  Updated to not declare
virtual methods in LCFilter.

Fixes: https://tracker.ceph.com/issues/76806
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_lc.h
src/rgw/rgw_lc_s3.cc

index b4cab41916d5429e2fd80f4c194d721702da45de..85570dd0c5f58d1b6fa2340f9b3f3c16a94281fc 100644 (file)
@@ -3,6 +3,7 @@
 
 #pragma once
 
+#include <cstdint>
 #include <map>
 #include <array>
 #include <string>
@@ -176,6 +177,7 @@ enum class LCFlagType : uint16_t
 {
   none = 0,
   ArchiveZone,
+  Filter,
 };
 
 class LCFlag {
@@ -201,11 +203,11 @@ class LCFilter
     }
    }
 
-  static constexpr std::array<LCFlag, 2> filter_flags =
-  {
-    LCFlag(LCFlagType::none, "none"),
-    LCFlag(LCFlagType::ArchiveZone, "ArchiveZone"),
-  };
+   static constexpr std::array<LCFlag, 3> filter_flags = {
+     LCFlag(LCFlagType::none, "none"),
+     LCFlag(LCFlagType::ArchiveZone, "ArchiveZone"),
+     LCFlag(LCFlagType::Filter, "Filter"),
+   };
 
 protected:
   std::string prefix;
@@ -217,7 +219,10 @@ protected:
 public:
 
   LCFilter() : flags(make_flag(LCFlagType::none))
-    {}
+  {}
+
+  ~LCFilter()
+  {}
 
   const std::string& get_prefix() const {
     return prefix;
@@ -231,6 +236,10 @@ public:
     return flags;
   }
 
+  void set_flag(LCFlagType flag) {
+    flags |= make_flag(flag);
+  }
+
   bool empty() const {
     return !(has_prefix() || has_tags() || has_flags() ||
             has_size_rule());
index eb8ff22ec5b86ab5f7c6236133c4129a5b49ab53..b84ba5a80c9b1e389453b614f627759a1c2938c6 100644 (file)
@@ -255,6 +255,8 @@ void LCRule_S3::decode_xml(XMLObj *obj)
     if (!RGWXMLDecoder::decode_xml("Prefix", prefix, obj)) {
       throw RGWXMLDecoder::err("missing Prefix in Filter");
     }
+  } else {
+    filter_s3.set_flag(LCFlagType::Filter);
   }
   filter = (LCFilter)filter_s3;