Skip to content

Conversation

@zhan7236
Copy link

Description

This PR fixes the issue where the enable_audit_log configuration was not taking effect, causing audit logs to always remain disabled even when explicitly set to true.

Fixes: #16706

Root Cause

The audit log configuration values were defined as static final fields in AbstractAuditLogger:

protected static final boolean IS_AUDIT_LOG_ENABLED = CONFIG.isEnableAuditLog(); private static final List<AuditLogOperation> AUDITABLE_OPERATION_TYPE = CONFIG.getAuditableOperationType(); private static final PrivilegeLevel AUDITABLE_OPERATION_LEVEL = CONFIG.getAuditableOperationLevel(); private static final String AUDITABLE_OPERATION_RESULT = CONFIG.getAuditableOperationResult();

These static final fields are initialized at class loading time, which may occur before the configuration file is fully loaded (especially in Docker environments where configuration is injected via environment variables). As a result, these values always get the default value (false for enable_audit_log).

Solution

Changed the static final fields to dynamic method calls that read the configuration values at runtime:

  • IS_AUDIT_LOG_ENABLEDisAuditLogEnabled() method
  • AUDITABLE_OPERATION_TYPEgetAuditableOperationType() method
  • AUDITABLE_OPERATION_LEVELgetAuditableOperationLevel() method
  • AUDITABLE_OPERATION_RESULTgetAuditableOperationResult() method

This ensures that the configuration values are read dynamically after the configuration file has been properly loaded.

Changed Files

  • AbstractAuditLogger.java
  • DNAuditLogger.java
  • CNAuditLogger.java

Testing

  • Code compiles successfully
  • Code style check passed (mvn spotless:check)

Checklist

  • I have read the Contributing Guidelines
  • I have searched for similar issues before creating this PR
  • The code follows the project's coding style
The audit log configuration (enable_audit_log) was not taking effect because the configuration values were stored as static final fields in AbstractAuditLogger, which were initialized at class loading time before the configuration file was fully loaded. This fix changes the static final fields to dynamic method calls: - IS_AUDIT_LOG_ENABLED -> isAuditLogEnabled() - AUDITABLE_OPERATION_TYPE -> getAuditableOperationType() - AUDITABLE_OPERATION_LEVEL -> getAuditableOperationLevel() - AUDITABLE_OPERATION_RESULT -> getAuditableOperationResult() This ensures that the configuration values are read dynamically at runtime, after the configuration file has been properly loaded. Fixes: apache#16706
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant