fix: resolve silent failure in MQTT bucket event notifications (#2112)

Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
simon-escapecode
2026-03-11 02:08:30 +00:00
committed by GitHub
parent 7e8c7fa2b2
commit f00d01ec2d
2 changed files with 12 additions and 26 deletions

View File

@@ -293,10 +293,17 @@ impl TargetRegistry {
}
}
let Some(store) = rustfs_ecstore::global::new_object_layer_fn() else {
return Err(TargetError::ServerNotInitialized(
"Failed to save target configuration: server storage not initialized".to_string(),
));
let store = match rustfs_ecstore::global::new_object_layer_fn() {
Some(s) => s,
None => {
warn!(
"Object store not available at notification init; skipping config persistence. \
{} target(s) active in memory.",
successful_targets.len()
);
info!(count = successful_targets.len(), "All target processing completed");
return Ok(successful_targets);
}
};
match rustfs_ecstore::config::com::save_server_config(store, &new_config).await {

View File

@@ -13,7 +13,6 @@
// limitations under the License.
use crate::app::context::resolve_server_config;
use rustfs_config::DEFAULT_DELIMITER;
use tracing::{error, info, instrument, warn};
fn server_config_from_context() -> Option<rustfs_ecstore::config::Config> {
@@ -58,32 +57,12 @@ pub(crate) async fn init_event_notifier() {
}
};
info!(
target: "rustfs::main::init_event_notifier",
"Global server configuration loaded successfully"
);
// 2. Check if at least one notify subsystem exists in the configuration, and skip only when neither is present.
let mqtt_configured = server_config
.get_value(rustfs_config::notify::NOTIFY_MQTT_SUB_SYS, DEFAULT_DELIMITER)
.is_some();
let webhook_configured = server_config
.get_value(rustfs_config::notify::NOTIFY_WEBHOOK_SUB_SYS, DEFAULT_DELIMITER)
.is_some();
if !mqtt_configured && !webhook_configured {
info!(
target: "rustfs::main::init_event_notifier",
"'notify' subsystem not configured, skipping event notifier initialization."
);
return;
}
info!(
target: "rustfs::main::init_event_notifier",
"Event notifier configuration found, proceeding with initialization."
);
// 3. Initialize the notification system asynchronously with a global configuration
// 2. Initialize the notification system asynchronously with a global configuration
// Use direct await for better error handling and faster initialization
if let Err(e) = rustfs_notify::initialize(server_config).await {
error!("Failed to initialize event notifier system: {}", e);