feat(ecstore): add RUSTFS_ILM_DEBUG_DAY_SECS lifecycle time-acceleration for tests (#4677)

feat(ecstore): add RUSTFS_ILM_DEBUG_DAY_SECS lifecycle time-acceleration for tests (backlog#1148 ilm-5)

Model a Ceph rgw_lc_debug_interval-style switch: when RUSTFS_ILM_DEBUG_DAY_SECS
is set to a positive integer N, lifecycle Days-based rule evaluation treats one
'day' as N seconds instead of 86400, so Days>=1 expiration/transition/noncurrent
rules become exercisable in seconds. Unset => byte-identical to production.

All Days->deadline conversions funnel through expected_expiry_time(); the new
ilm_day_secs() helper (OnceLock-cached in production, env-read under cfg(test))
rescales both the day offset and the default rounding boundary. An explicit
RUSTFS_ILM_PROCESS_TIME still wins for the rounding boundary. Absolute Date-based
rules are deliberately NOT rescaled. Activation emits a WARN; test/debug only.

Refs rustfs/backlog#1148 (ilm-5), rustfs/backlog#1155.
This commit is contained in:
Zhengchao An
2026-07-10 21:57:19 +08:00
committed by GitHub
parent 6fed0a4067
commit 40875026df
2 changed files with 363 additions and 8 deletions
+18
View File
@@ -41,6 +41,24 @@ pub const ENV_ILM_PROCESS_TIME_DEPRECATED: &str = "_RUSTFS_ILM_PROCESS_TIME";
/// Default ILM process boundary in seconds (24h).
pub const DEFAULT_ILM_PROCESS_TIME_SECS: i32 = 86400;
/// **TEST/DEBUG ONLY** — lifecycle "day" length override, in seconds.
///
/// Modeled on Ceph RGW's `rgw_lc_debug_interval`. When set to a positive
/// integer `N`, lifecycle rule evaluation treats one Days-based "day" as `N`
/// seconds instead of [`DEFAULT_ILM_DAY_SECS`] (86400), so `Days`-based
/// expiration/transition/noncurrent rules become exercisable in seconds under
/// test. When unset (or set to `0`/an invalid value), behavior is byte-for-byte
/// identical to production.
///
/// This accelerates data deletion and MUST NEVER be set in a production
/// deployment. Enabling it emits a `WARN` log. It only rescales relative
/// `Days` deadlines; absolute `Date`-based rules are unaffected.
pub const ENV_ILM_DEBUG_DAY_SECS: &str = "RUSTFS_ILM_DEBUG_DAY_SECS";
/// Number of seconds in one lifecycle "day" (86400) used as the default when
/// [`ENV_ILM_DEBUG_DAY_SECS`] is unset.
pub const DEFAULT_ILM_DAY_SECS: u32 = 86400;
/// Medium-drawn lines separator
/// This is used to separate words in environment variable names.
pub const ENV_WORD_DELIMITER_DASH: &str = "-";