jerryshao opened a new pull request, #11191:
URL: https://github.com/apache/gravitino/pull/11191

   ## What changes were proposed in this pull request?
   
   Fixes three audit log bugs from #11170:
   
   **Problem 1 — FileAuditWriter has no file rotation, compression, or 
retention**
   - Rewrite `FileAuditWriter` to delegate all file management to Log4j2 via a
     dedicated SLF4J logger named `gravitino.audit`
   - Add `audit_file` rolling appender group to 
`conf/log4j2.properties.template`:
     256 MB or daily rotation, gzip compression, 30-day retention
   - Deprecated writer properties (`fileName`, `append`, `flushIntervalSecs`) 
now
     emit a `WARN` log at startup and are otherwise ignored
   - Update `gravitino-server-config.md` with migration guidance
   
   **Problem 3 — remoteAddress() always returns "unknown" for Gravitino server 
events**
   - Add `RequestContext` ThreadLocal in `core/` to hold the client IP on the 
servlet thread
   - Read the value at `Event` construction time (not at listener processing 
time),
     so async listener threads safely read a `final` field instead of 
ThreadLocal
   - Add `RequestContextFilter` in `server/` to set/clear the value around each
     request, honoring `X-Forwarded-For` for reverse-proxy deployments
   - Apply the same `X-Forwarded-For` logic to `IcebergRequestContext`
   
   **Problem 4 — SimpleAuditLogV2 uses second-precision timestamps and omits 
customInfo**
   - Replace `new SimpleDateFormat(...)` per call with a static thread-safe
     `DateTimeFormatter` at millisecond precision (`yyyy-MM-dd HH:mm:ss.SSS`)
   - Append `customInfo()` as an 8th tab-separated field (empty string when 
absent)
   
   ## How was this patch tested?
   
   - `TestRequestContext` — ThreadLocal set/get/clear/thread-isolation
   - `TestEventRemoteAddress` — value captured at construction time, survives 
ThreadLocal clear
   - `TestRequestContextFilter` — X-Forwarded-For (single/multi-entry), 
fallback to `getRemoteAddr()`, cleanup in finally including on exception
   - `TestSimpleAuditLogV2` — millisecond precision, 8-field output, customInfo 
presence/absence
   - `TestFileAuditWriter` — doWrite publishes to audit logger, deprecated keys 
emit WARN, clean properties emit no WARN, close is no-op
   - `TestAuditManager` — default writer/formatter types, batch dispatch smoke 
test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to