mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-04 11:15:39 +00:00
Adding a toggle for update check (#532)
This commit is contained in:
@@ -79,3 +79,13 @@ pub const ENV_CONSOLE_AUTH_TIMEOUT: &str = "RUSTFS_CONSOLE_AUTH_TIMEOUT";
|
|||||||
/// Example: RUSTFS_CONSOLE_AUTH_TIMEOUT=3600
|
/// Example: RUSTFS_CONSOLE_AUTH_TIMEOUT=3600
|
||||||
/// Example: --console-auth-timeout 3600
|
/// Example: --console-auth-timeout 3600
|
||||||
pub const DEFAULT_CONSOLE_AUTH_TIMEOUT: u64 = 3600;
|
pub const DEFAULT_CONSOLE_AUTH_TIMEOUT: u64 = 3600;
|
||||||
|
|
||||||
|
/// Toggle update check
|
||||||
|
/// It controls whether to check for newer versions of rustfs
|
||||||
|
/// Default value: true
|
||||||
|
/// Environment variable: RUSTFS_CHECK_UPDATE
|
||||||
|
/// Example: RUSTFS_CHECK_UPDATE=false
|
||||||
|
pub const ENV_UPDATE_CHECK: &str = "RUSTFS_CHECK_UPDATE";
|
||||||
|
|
||||||
|
/// Default value for update toggle
|
||||||
|
pub const DEFAULT_UPDATE_CHECK: bool = true;
|
||||||
|
|||||||
+50
-35
@@ -41,6 +41,8 @@ use rustfs_ahm::{
|
|||||||
};
|
};
|
||||||
use rustfs_common::globals::set_global_addr;
|
use rustfs_common::globals::set_global_addr;
|
||||||
use rustfs_config::DEFAULT_DELIMITER;
|
use rustfs_config::DEFAULT_DELIMITER;
|
||||||
|
use rustfs_config::DEFAULT_UPDATE_CHECK;
|
||||||
|
use rustfs_config::ENV_UPDATE_CHECK;
|
||||||
use rustfs_ecstore::bucket::metadata_sys;
|
use rustfs_ecstore::bucket::metadata_sys;
|
||||||
use rustfs_ecstore::bucket::metadata_sys::init_bucket_metadata_sys;
|
use rustfs_ecstore::bucket::metadata_sys::init_bucket_metadata_sys;
|
||||||
use rustfs_ecstore::cmd::bucket_replication::init_bucket_replication_pool;
|
use rustfs_ecstore::cmd::bucket_replication::init_bucket_replication_pool;
|
||||||
@@ -324,41 +326,7 @@ async fn run(opt: config::Opt) -> Result<()> {
|
|||||||
// initialize bucket replication pool
|
// initialize bucket replication pool
|
||||||
init_bucket_replication_pool().await;
|
init_bucket_replication_pool().await;
|
||||||
|
|
||||||
// Async update check with timeout (optional)
|
init_update_check();
|
||||||
tokio::spawn(async {
|
|
||||||
use crate::update::{UpdateCheckError, check_updates};
|
|
||||||
|
|
||||||
// Add timeout to prevent hanging network calls
|
|
||||||
match tokio::time::timeout(std::time::Duration::from_secs(30), check_updates()).await {
|
|
||||||
Ok(Ok(result)) => {
|
|
||||||
if result.update_available {
|
|
||||||
if let Some(latest) = &result.latest_version {
|
|
||||||
info!(
|
|
||||||
"🚀 Version check: New version available: {} -> {} (current: {})",
|
|
||||||
result.current_version, latest.version, result.current_version
|
|
||||||
);
|
|
||||||
if let Some(notes) = &latest.release_notes {
|
|
||||||
info!("📝 Release notes: {}", notes);
|
|
||||||
}
|
|
||||||
if let Some(url) = &latest.download_url {
|
|
||||||
info!("🔗 Download URL: {}", url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug!("✅ Version check: Current version is up to date: {}", result.current_version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(Err(UpdateCheckError::HttpError(e))) => {
|
|
||||||
debug!("Version check: network error (this is normal): {}", e);
|
|
||||||
}
|
|
||||||
Ok(Err(e)) => {
|
|
||||||
debug!("Version check: failed (this is normal): {}", e);
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
debug!("Version check: timeout after 30 seconds (this is normal)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// if opt.console_enable {
|
// if opt.console_enable {
|
||||||
// debug!("console is enabled");
|
// debug!("console is enabled");
|
||||||
@@ -476,6 +444,53 @@ async fn init_event_notifier() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn init_update_check() {
|
||||||
|
let update_check_enable = std::env::var(ENV_UPDATE_CHECK)
|
||||||
|
.unwrap_or_else(|_| DEFAULT_UPDATE_CHECK.to_string())
|
||||||
|
.parse::<bool>()
|
||||||
|
.unwrap_or(DEFAULT_UPDATE_CHECK);
|
||||||
|
|
||||||
|
if !update_check_enable {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Async update check with timeout
|
||||||
|
tokio::spawn(async {
|
||||||
|
use crate::update::{UpdateCheckError, check_updates};
|
||||||
|
|
||||||
|
// Add timeout to prevent hanging network calls
|
||||||
|
match tokio::time::timeout(std::time::Duration::from_secs(30), check_updates()).await {
|
||||||
|
Ok(Ok(result)) => {
|
||||||
|
if result.update_available {
|
||||||
|
if let Some(latest) = &result.latest_version {
|
||||||
|
info!(
|
||||||
|
"🚀 Version check: New version available: {} -> {} (current: {})",
|
||||||
|
result.current_version, latest.version, result.current_version
|
||||||
|
);
|
||||||
|
if let Some(notes) = &latest.release_notes {
|
||||||
|
info!("📝 Release notes: {}", notes);
|
||||||
|
}
|
||||||
|
if let Some(url) = &latest.download_url {
|
||||||
|
info!("🔗 Download URL: {}", url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debug!("✅ Version check: Current version is up to date: {}", result.current_version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(Err(UpdateCheckError::HttpError(e))) => {
|
||||||
|
debug!("Version check: network error (this is normal): {}", e);
|
||||||
|
}
|
||||||
|
Ok(Err(e)) => {
|
||||||
|
debug!("Version check: failed (this is normal): {}", e);
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
debug!("Version check: timeout after 30 seconds (this is normal)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
async fn add_bucket_notification_configuration(buckets: Vec<String>) {
|
async fn add_bucket_notification_configuration(buckets: Vec<String>) {
|
||||||
let region_opt = rustfs_ecstore::global::get_global_region();
|
let region_opt = rustfs_ecstore::global::get_global_region();
|
||||||
|
|||||||
Reference in New Issue
Block a user