summaryrefslogtreecommitdiffstats
path: root/src/rgw/rgw_lc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rgw/rgw_lc.cc')
-rw-r--r--src/rgw/rgw_lc.cc59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc
index 7f4a79501..74bc8b12c 100644
--- a/src/rgw/rgw_lc.cc
+++ b/src/rgw/rgw_lc.cc
@@ -41,6 +41,9 @@
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw
+constexpr int32_t hours_in_a_day = 24;
+constexpr int32_t secs_in_a_day = hours_in_a_day * 60 * 60;
+
using namespace std;
const char* LC_STATUS[] = {
@@ -289,7 +292,7 @@ static bool obj_has_expired(const DoutPrefixProvider *dpp, CephContext *cct, cep
utime_t base_time;
if (cct->_conf->rgw_lc_debug_interval <= 0) {
/* Normal case, run properly */
- cmp = double(days)*24*60*60;
+ cmp = double(days) * secs_in_a_day;
base_time = ceph_clock_now().round_to_day();
} else {
/* We're in debug mode; Treat each rgw_lc_debug_interval seconds as a day */
@@ -509,6 +512,28 @@ struct lc_op_ctx {
static std::string lc_id = "rgw lifecycle";
static std::string lc_req_id = "0";
+/* do all zones in the zone group process LC? */
+static bool zonegroup_lc_check(const DoutPrefixProvider *dpp, rgw::sal::Zone* zone)
+{
+ auto& zonegroup = zone->get_zonegroup();
+ std::list<std::string> ids;
+ int ret = zonegroup.list_zones(ids);
+ if (ret < 0) {
+ return false;
+ }
+
+ return std::all_of(ids.begin(), ids.end(), [&](const auto& id) {
+ std::unique_ptr<rgw::sal::Zone> zone;
+ ret = zonegroup.get_zone_by_id(id, &zone);
+ if (ret < 0) {
+ return false;
+ }
+ const auto& tier_type = zone->get_tier_type();
+ ldpp_dout(dpp, 20) << "checking zone tier_type=" << tier_type << dendl;
+ return (tier_type == "rgw" || tier_type == "archive" || tier_type == "");
+ });
+}
+
static int remove_expired_obj(
const DoutPrefixProvider *dpp, lc_op_ctx& oc, bool remove_indeed,
rgw::notify::EventType event_type)
@@ -579,7 +604,10 @@ static int remove_expired_obj(
<< dendl;
return ret;
}
- ret = del_op->delete_obj(dpp, null_yield);
+
+ uint32_t flags = (!remove_indeed || !zonegroup_lc_check(dpp, oc.driver->get_zone()))
+ ? rgw::sal::FLAG_LOG_OP : 0;
+ ret = del_op->delete_obj(dpp, null_yield, flags);
if (ret < 0) {
ldpp_dout(dpp, 1) <<
"ERROR: publishing notification failed, with error: " << ret << dendl;
@@ -843,6 +871,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
if (obj_has_expired(this, cct, obj.meta.mtime, rule.mp_expiration)) {
rgw_obj_key key(obj.key);
std::unique_ptr<rgw::sal::MultipartUpload> mpu = target->get_multipart_upload(key.name);
+
int ret = mpu->abort(this, cct);
if (ret == 0) {
if (perfcounter) {
@@ -1353,8 +1382,10 @@ public:
return -EINVAL;
}
+ uint32_t flags = !zonegroup_lc_check(oc.dpp, oc.driver->get_zone())
+ ? rgw::sal::FLAG_LOG_OP : 0;
int r = oc.obj->transition(oc.bucket, target_placement, o.meta.mtime,
- o.versioned_epoch, oc.dpp, null_yield);
+ o.versioned_epoch, oc.dpp, null_yield, flags);
if (r < 0) {
ldpp_dout(oc.dpp, 0) << "ERROR: failed to transition obj "
<< oc.bucket << ":" << o.key
@@ -1874,8 +1905,7 @@ bool RGWLC::expired_session(time_t started)
}
time_t interval = (cct->_conf->rgw_lc_debug_interval > 0)
- ? cct->_conf->rgw_lc_debug_interval
- : 24*60*60;
+ ? cct->_conf->rgw_lc_debug_interval : secs_in_a_day;
auto now = time(nullptr);
@@ -1891,8 +1921,7 @@ bool RGWLC::expired_session(time_t started)
time_t RGWLC::thread_stop_at()
{
uint64_t interval = (cct->_conf->rgw_lc_debug_interval > 0)
- ? cct->_conf->rgw_lc_debug_interval
- : 24*60*60;
+ ? cct->_conf->rgw_lc_debug_interval : secs_in_a_day;
return time(nullptr) + interval;
}
@@ -1983,7 +2012,7 @@ static inline bool allow_shard_rollover(CephContext* cct, time_t now, time_t sha
* - the current shard has not rolled over in the last 24 hours
*/
if (((shard_rollover_date < now) &&
- (now - shard_rollover_date > 24*60*60)) ||
+ (now - shard_rollover_date > secs_in_a_day)) ||
(! shard_rollover_date /* no rollover date stored */) ||
(cct->_conf->rgw_lc_debug_interval > 0 /* defaults to -1 == disabled */)) {
return true;
@@ -2009,7 +2038,7 @@ static inline bool already_run_today(CephContext* cct, time_t start_date)
bdt.tm_min = 0;
bdt.tm_sec = 0;
begin_of_day = mktime(&bdt);
- if (now - begin_of_day < 24*60*60)
+ if (now - begin_of_day < secs_in_a_day)
return true;
else
return false;
@@ -2346,6 +2375,12 @@ bool RGWLC::LCWorker::should_work(utime_t& now)
time_t tt = now.sec();
localtime_r(&tt, &bdt);
+ // next-day adjustment if the configured end_hour is less than start_hour
+ if (end_hour < start_hour) {
+ bdt.tm_hour = bdt.tm_hour > end_hour ? bdt.tm_hour : bdt.tm_hour + hours_in_a_day;
+ end_hour += hours_in_a_day;
+ }
+
if (cct->_conf->rgw_lc_debug_interval > 0) {
/* We're debugging, so say we can run */
return true;
@@ -2386,7 +2421,7 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
nt = mktime(&bdt);
secs = nt - tt;
- return secs>0 ? secs : secs+24*60*60;
+ return secs > 0 ? secs : secs + secs_in_a_day;
}
RGWLC::LCWorker::~LCWorker()
@@ -2677,7 +2712,7 @@ std::string s3_expiration_header(
if (rule_expiration.has_days()) {
rule_expiration_date =
boost::optional<ceph::real_time>(
- mtime + make_timespan(double(rule_expiration.get_days())*24*60*60 - ceph::real_clock::to_time_t(mtime)%(24*60*60) + 24*60*60));
+ mtime + make_timespan(double(rule_expiration.get_days()) * secs_in_a_day - ceph::real_clock::to_time_t(mtime)%(secs_in_a_day) + secs_in_a_day));
}
}
@@ -2756,7 +2791,7 @@ bool s3_multipart_abort_header(
std::optional<ceph::real_time> rule_abort_date;
if (mp_expiration.has_days()) {
rule_abort_date = std::optional<ceph::real_time>(
- mtime + make_timespan(mp_expiration.get_days()*24*60*60 - ceph::real_clock::to_time_t(mtime)%(24*60*60) + 24*60*60));
+ mtime + make_timespan(mp_expiration.get_days() * secs_in_a_day - ceph::real_clock::to_time_t(mtime)%(secs_in_a_day) + secs_in_a_day));
}
// update earliest abort date