From e08cf474db104c00de92eae7fa519abbf3dcc618 Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Tue, 4 Aug 2026 11:45:48 +0800 Subject: [PATCH] fix(audit): move audit init after IAM bootstrap to fix startup ordering (#5685) Audit initialization requires the AppContext (server config + object store) which is published by ensure_startup_after_iam inside init_iam_runtime. Moving init_audit_runtime after init_iam_runtime ensures the runtime sources are available when audit starts. Fixes #5681 Co-authored-by: RustFS --- rustfs/src/startup_services.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rustfs/src/startup_services.rs b/rustfs/src/startup_services.rs index 7a587ddec..585e9677a 100644 --- a/rustfs/src/startup_services.rs +++ b/rustfs/src/startup_services.rs @@ -75,11 +75,14 @@ pub(crate) async fn init_startup_runtime_services( let optional_runtimes = init_optional_runtime_services().await?; init_buffer_profile_system(config); - init_audit_runtime().await; init_deadlock_detector_runtime(); let buckets = init_bucket_metadata_runtime(store.clone(), ctx.clone()).await?; let iam_bootstrap = init_iam_runtime(store.clone(), ctx.clone(), readiness, state_manager, server_ctx).await?; + + // Audit initialization requires the AppContext (server config + object store) + // which is published by ensure_startup_after_iam inside init_iam_runtime. + init_audit_runtime().await; // Unconditional: deferred IAM recovers in the background and has no callback into this // scheduler, so gating on the inline disposition would leave a recovered node with // self-pointing replication rules until the next restart. The task waits for IAM and