mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-06 03:59:14 +00:00
feat(odm): enable on-demand migration by default (#7089)
* feat(odm): enable on-demand migration by default The module switch RUSTFS_ON_DEMAND_MIGRATION_ENABLED now defaults to true, so the feature is reachable without an opt-in; setting it to false still keeps the module out of the read path entirely. A bucket without an on-demand-migration.json is never resolved by the runtime and makes no source call, so the flip changes nothing for unconfigured buckets. The admin plane now reads the switch through the predicate published by module_switches.rs instead of its own duplicated env constant; the behaviour (an environment read per call) is unchanged. * test(e2e): wire three on-demand migration cases into e2e-smoke The PR smoke lane gains one case per user-visible contract: a GET miss that pulls and persists, a HEAD miss that answers from the source and stores nothing, and the admin config/status pair that must redact the source secret. The HEAD case did not exist outside the nightly real-source lane, so it is added to get_basic_test. Measured on darwin: the lane goes from 168 tests in 101.98 s to 171 tests in 101.92 s, since the three cases overlap the lane's existing work. The darwin selection digests for e2e-smoke and e2e-full are regenerated; the e2e-full linux digest still needs a Linux runner. * docs(changelog): record the on-demand migration feature
This commit is contained in:
@@ -54,6 +54,7 @@ use crate::admin::storage_api::s3::{Body, S3Error, S3ErrorCode, S3Request, S3Res
|
||||
use crate::admin::utils::{extract_query_params, read_compatible_admin_body};
|
||||
use crate::error::ApiError;
|
||||
use crate::license::license_check;
|
||||
use crate::module_switches::{ENV_ON_DEMAND_MIGRATION_ENABLED, on_demand_migration_enabled_from_env};
|
||||
use crate::server::ADMIN_PREFIX;
|
||||
use hyper::{Method, StatusCode};
|
||||
use matchit::Params;
|
||||
@@ -93,13 +94,12 @@ pub(crate) const ERR_CODE_BACKFILL_RUNNING: &str = "OnDemandMigrationBackfillRun
|
||||
/// Error code (404) returned when the bucket never had a backfill job.
|
||||
pub(crate) const ERR_CODE_NO_SUCH_BACKFILL_JOB: &str = "NoSuchBackfillJob";
|
||||
|
||||
/// The published switch is `RUSTFS_ON_DEMAND_MIGRATION_ENABLED`, owned by
|
||||
/// ODM-05 in `module_switches.rs`. This is the only read of it in the admin
|
||||
/// plane so the orchestrator can swap the call for the published predicate.
|
||||
const ENV_ON_DEMAND_MIGRATION_ENABLED: &str = "RUSTFS_ON_DEMAND_MIGRATION_ENABLED";
|
||||
|
||||
/// The switch is `RUSTFS_ON_DEMAND_MIGRATION_ENABLED`, owned by ODM-05 in
|
||||
/// `module_switches.rs`. The admin plane resolves it from the environment on
|
||||
/// every call rather than from the published cell, so an admin request answers
|
||||
/// the switch the process was started with even before startup published it.
|
||||
fn module_enabled() -> bool {
|
||||
rustfs_utils::get_env_bool(ENV_ON_DEMAND_MIGRATION_ENABLED, false)
|
||||
on_demand_migration_enabled_from_env()
|
||||
}
|
||||
|
||||
/// What the source answered during `PUT` validation.
|
||||
@@ -1278,8 +1278,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_switch_defaults_off_and_reads_the_env() {
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, None::<&str>, || assert!(!module_enabled()));
|
||||
fn module_switch_defaults_on_and_reads_the_env() {
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, None::<&str>, || assert!(module_enabled()));
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, Some("true"), || assert!(module_enabled()));
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, Some("false"), || assert!(!module_enabled()));
|
||||
}
|
||||
|
||||
@@ -35,10 +35,11 @@ pub(crate) const ENV_HEAL_ENABLED: &str = "RUSTFS_HEAL_ENABLED";
|
||||
pub(crate) const ENV_HEAL_ENABLED_DEPRECATED: &str = "RUSTFS_ENABLE_HEAL";
|
||||
pub(crate) const ENV_BITROT_SELFTEST_ENABLE: &str = "RUSTFS_BITROT_SELFTEST_ENABLE";
|
||||
pub(crate) const ENV_BITROT_SELFTEST_STRICT: &str = "RUSTFS_BITROT_SELFTEST_STRICT";
|
||||
/// On-demand migration module switch (rustfs/backlog#2152). Off until GA
|
||||
/// (rustfs/backlog#2163) so every intermediate PR ships dark.
|
||||
/// On-demand migration module switch (rustfs/backlog#2152). On since GA
|
||||
/// (rustfs/backlog#2163); set it to `false` to keep the module out of the
|
||||
/// read path entirely.
|
||||
pub(crate) const ENV_ON_DEMAND_MIGRATION_ENABLED: &str = "RUSTFS_ON_DEMAND_MIGRATION_ENABLED";
|
||||
pub(crate) const DEFAULT_ON_DEMAND_MIGRATION_ENABLED: bool = false;
|
||||
pub(crate) const DEFAULT_ON_DEMAND_MIGRATION_ENABLED: bool = true;
|
||||
|
||||
static AUDIT_MODULE_ENABLED: AtomicBool = AtomicBool::new(rustfs_config::DEFAULT_AUDIT_ENABLE);
|
||||
static NOTIFY_MODULE_ENABLED: AtomicBool = AtomicBool::new(rustfs_config::DEFAULT_NOTIFY_ENABLE);
|
||||
@@ -86,7 +87,7 @@ pub(crate) fn set_notify_module_enabled(enabled: bool) {
|
||||
NOTIFY_MODULE_ENABLED.store(enabled, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Whether the on-demand migration module is enabled, defaulting to off.
|
||||
/// Whether the on-demand migration module is enabled, defaulting to on.
|
||||
/// Read once at startup by `startup_bucket_metadata` and published below.
|
||||
pub(crate) fn on_demand_migration_enabled_from_env() -> bool {
|
||||
rustfs_utils::get_env_bool(ENV_ON_DEMAND_MIGRATION_ENABLED, DEFAULT_ON_DEMAND_MIGRATION_ENABLED)
|
||||
@@ -110,15 +111,18 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn on_demand_migration_switch_defaults_off_and_follows_env() {
|
||||
fn on_demand_migration_switch_defaults_on_and_follows_env() {
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, None::<&str>, || {
|
||||
assert!(!on_demand_migration_enabled_from_env());
|
||||
assert!(on_demand_migration_enabled_from_env());
|
||||
});
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, Some("false"), || {
|
||||
assert!(!on_demand_migration_enabled_from_env(), "the off switch still works");
|
||||
});
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, Some("true"), || {
|
||||
assert!(on_demand_migration_enabled_from_env());
|
||||
});
|
||||
temp_env::with_var(ENV_ON_DEMAND_MIGRATION_ENABLED, Some("not-a-bool"), || {
|
||||
assert!(!on_demand_migration_enabled_from_env(), "unparsable values keep the default");
|
||||
assert!(on_demand_migration_enabled_from_env(), "unparsable values keep the default");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user