fix(audit): prevent state transition when no targets exist (#854)

Avoid setting AuditSystemState::Starting when target list is empty.
Now checks target availability before state transition, keeping the
system in Stopped state if no enabled targets are found.

- Check targets.is_empty() before setting Starting state
- Return early with Ok(()) when no targets exist
- Maintain consistent state machine behavior
- Prevent transient "Starting" state with no actual targets

Resolves issue where audit system would incorrectly enter Starting
state even when configuration contained no enabled targets.
This commit is contained in:
houseme
2025-11-14 20:23:21 +08:00
committed by GitHub
parent 3cf565e847
commit 55e3a1f7e0
5 changed files with 19 additions and 9 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ use rustfs_audit::system::AuditSystemState;
use rustfs_audit::{AuditError, AuditResult, audit_system, init_audit_system};
use rustfs_config::DEFAULT_DELIMITER;
use rustfs_ecstore::config::GLOBAL_SERVER_CONFIG;
use tracing::{error, info, warn};
use tracing::{info, warn};
/// Start the audit system.
/// This function checks if the audit subsystem is configured in the global server configuration.
@@ -89,7 +89,7 @@ pub(crate) async fn start_audit_system() -> AuditResult<()> {
Ok(())
}
Err(e) => {
error!(
warn!(
target: "rustfs::main::start_audit_system",
"Audit system startup failed: {:?}",
e