mirror of
https://github.com/rustfs/rustfs.git
synced 2026-03-17 14:24:08 +00:00
chore: align env var naming conventions
This commit is contained in:
@@ -71,8 +71,10 @@ Co-locate unit tests with their modules and give behavior-led names. Integration
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `RUSTFS_ENABLE_SCANNER` - Enable/disable background data scanner (default: true)
|
||||
- `RUSTFS_ENABLE_HEAL` - Enable/disable auto-heal functionality (default: true)
|
||||
- Global configuration environment variables must use flat `RUSTFS_*` names (no module segments), such as `RUSTFS_REGION`, `RUSTFS_ADDRESS`, `RUSTFS_VOLUMES`, and `RUSTFS_LICENSE`.
|
||||
- `RUSTFS_SCANNER_ENABLED` - Enable/disable background data scanner (default: true)
|
||||
- `RUSTFS_HEAL_ENABLED` - Enable/disable auto-heal functionality (default: true)
|
||||
- Deprecated aliases (for pre-beta compatibility) are documented in [the config module README](crates/config/README.md#environment-variable-naming-conventions) and must log warnings when used.
|
||||
- For KMS tests: `NO_PROXY=127.0.0.1,localhost` and clear proxy environment variables
|
||||
|
||||
## Commit & Pull Request Guidelines
|
||||
|
||||
@@ -32,6 +32,24 @@
|
||||
|
||||
For comprehensive documentation, examples, and usage guides, please visit the main [RustFS repository](https://github.com/rustfs/rustfs).
|
||||
|
||||
## Environment Variable Naming Conventions
|
||||
|
||||
RustFS uses a flat naming style for top-level configuration: environment variables are `RUSTFS_*` without nested module segments.
|
||||
|
||||
Examples:
|
||||
- `RUSTFS_REGION`
|
||||
- `RUSTFS_ADDRESS`
|
||||
- `RUSTFS_VOLUMES`
|
||||
- `RUSTFS_LICENSE`
|
||||
|
||||
Current guidance:
|
||||
- Prefer module-specific names only when they are not top-level product configuration.
|
||||
- Renamed variables must keep backward-compatible aliases until before beta.
|
||||
- Alias usage must emit deprecation warnings and be treated as transitional only.
|
||||
- Deprecated example:
|
||||
- `RUSTFS_ENABLE_SCANNER` -> `RUSTFS_SCANNER_ENABLED`
|
||||
- `RUSTFS_ENABLE_HEAL` -> `RUSTFS_HEAL_ENABLED`
|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is licensed under the Apache License 2.0 - see the [LICENSE](../../LICENSE) file for details.
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
//! Disabled lock manager that bypasses all locking operations
|
||||
//! Used when RUSTFS_ENABLE_LOCKS environment variable is set to false
|
||||
//! Used when the lock feature is disabled via RUSTFS_LOCK_ENABLED
|
||||
//! (or deprecated RUSTFS_ENABLE_LOCKS).
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
@@ -69,7 +69,9 @@ pub const BUILD_TIMESTAMP: &str = "unknown";
|
||||
/// Maximum number of items in delete list
|
||||
pub const MAX_DELETE_LIST: usize = 1000;
|
||||
|
||||
/// Default setting for RUSTFS_ENABLE_LOCKS environment variable
|
||||
/// Default setting for lock enablement.
|
||||
/// Canonical variable: RUSTFS_LOCK_ENABLED
|
||||
/// Deprecated compatibility alias: RUSTFS_ENABLE_LOCKS
|
||||
const DEFAULT_RUSTFS_LOCKS_ENABLED: bool = true;
|
||||
const ENV_LOCK_ENABLED: &str = "RUSTFS_LOCK_ENABLED";
|
||||
const ENV_LOCK_ENABLED_DEPRECATED: &str = "RUSTFS_ENABLE_LOCKS";
|
||||
@@ -99,14 +101,26 @@ impl Default for GlobalLockManager {
|
||||
impl GlobalLockManager {
|
||||
/// Create a lock manager based on environment variable configuration
|
||||
pub fn new() -> Self {
|
||||
// Check RUSTFS_ENABLE_LOCKS environment variable
|
||||
// Check lock enablement env vars with deprecated compatibility support.
|
||||
let locks_enabled = rustfs_utils::get_env_bool_with_aliases(
|
||||
ENV_LOCK_ENABLED,
|
||||
&[ENV_LOCK_ENABLED_DEPRECATED],
|
||||
DEFAULT_RUSTFS_LOCKS_ENABLED,
|
||||
);
|
||||
if !locks_enabled {
|
||||
tracing::info!("Lock system disabled via {} environment variable", ENV_LOCK_ENABLED_DEPRECATED);
|
||||
let disabled_by = if std::env::var(ENV_LOCK_ENABLED).is_ok() {
|
||||
ENV_LOCK_ENABLED
|
||||
} else if std::env::var(ENV_LOCK_ENABLED_DEPRECATED).is_ok() {
|
||||
ENV_LOCK_ENABLED_DEPRECATED
|
||||
} else {
|
||||
"default setting"
|
||||
};
|
||||
|
||||
if disabled_by == "default setting" {
|
||||
tracing::info!("Lock system disabled via default setting");
|
||||
} else {
|
||||
tracing::info!("Lock system disabled via {} environment variable", disabled_by);
|
||||
}
|
||||
return Self::Disabled(DisabledLockManager::new());
|
||||
}
|
||||
tracing::info!("Lock system enabled");
|
||||
@@ -254,7 +268,7 @@ static GLOBAL_LOCK_MANAGER: OnceLock<Arc<GlobalLockManager>> = OnceLock::new();
|
||||
/// Get the global shared lock manager instance
|
||||
///
|
||||
/// Returns either FastObjectLockManager or DisabledLockManager based on
|
||||
/// the RUSTFS_ENABLE_LOCKS environment variable.
|
||||
/// the RUSTFS_LOCK_ENABLED environment variable.
|
||||
pub fn get_global_lock_manager() -> Arc<GlobalLockManager> {
|
||||
GLOBAL_LOCK_MANAGER.get_or_init(|| Arc::new(GlobalLockManager::new())).clone()
|
||||
}
|
||||
|
||||
@@ -73,10 +73,12 @@ static WARNED_ENV_MESSAGES: OnceLock<Mutex<HashSet<String>>> = OnceLock::new();
|
||||
|
||||
fn log_once(key: &str, message: impl FnOnce() -> String) {
|
||||
let seen = WARNED_ENV_MESSAGES.get_or_init(|| Mutex::new(HashSet::new()));
|
||||
if let Ok(mut seen) = seen.lock() {
|
||||
if seen.insert(key.to_string()) {
|
||||
warn!("{}", message());
|
||||
}
|
||||
let mut seen = match seen.lock() {
|
||||
Ok(seen) => seen,
|
||||
Err(poisoned) => poisoned.into_inner(),
|
||||
};
|
||||
if seen.insert(key.to_string()) {
|
||||
warn!("{}", message());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,8 +156,8 @@ $env:RUSTFS_NS_SCANNER_INTERVAL = "60"
|
||||
|
||||
# $env:RUSTFS_REGION = "us-east-1"
|
||||
|
||||
$env:RUSTFS_ENABLE_SCANNER = "false"
|
||||
$env:RUSTFS_ENABLE_HEAL = "false"
|
||||
$env:RUSTFS_SCANNER_ENABLED = "false"
|
||||
$env:RUSTFS_HEAL_ENABLED = "false"
|
||||
|
||||
# Object cache configuration
|
||||
$env:RUSTFS_OBJECT_CACHE_ENABLE = "true"
|
||||
@@ -198,4 +198,4 @@ if (-not $env:MALLOC_CONF) {
|
||||
# To run in release mode:
|
||||
# cargo run --profile release --bin rustfs
|
||||
# To run in debug mode:
|
||||
cargo run --bin rustfs
|
||||
cargo run --bin rustfs
|
||||
|
||||
@@ -178,9 +178,9 @@ export RUSTFS_NS_SCANNER_INTERVAL=60 # Object scanning interval in seconds
|
||||
|
||||
#export RUSTFS_REGION="us-east-1"
|
||||
|
||||
export RUSTFS_ENABLE_SCANNER=true
|
||||
export RUSTFS_SCANNER_ENABLED=true
|
||||
|
||||
export RUSTFS_ENABLE_HEAL=true
|
||||
export RUSTFS_HEAL_ENABLED=true
|
||||
|
||||
# Object cache configuration
|
||||
export RUSTFS_OBJECT_CACHE_ENABLE=true
|
||||
@@ -252,4 +252,4 @@ fi
|
||||
# To run in release mode, use the following line
|
||||
#cargo run --profile release --bin rustfs
|
||||
# To run in debug mode, use the following line
|
||||
cargo run --bin rustfs
|
||||
cargo run --bin rustfs
|
||||
|
||||
Reference in New Issue
Block a user