From: Matt Benjamin Date: Wed, 27 May 2026 04:14:17 +0000 (-0400) Subject: rgwlc: faithfully store lifecycle filters X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=47c6618d8138928abf5ce337d0f0fb3b91de02ef;p=ceph.git rgwlc: faithfully store lifecycle filters 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 --- diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index b4cab41916d..85570dd0c5f 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -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 filter_flags = - { - LCFlag(LCFlagType::none, "none"), - LCFlag(LCFlagType::ArchiveZone, "ArchiveZone"), - }; + static constexpr std::array 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()); diff --git a/src/rgw/rgw_lc_s3.cc b/src/rgw/rgw_lc_s3.cc index eb8ff22ec5b..b84ba5a80c9 100644 --- a/src/rgw/rgw_lc_s3.cc +++ b/src/rgw/rgw_lc_s3.cc @@ -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;