doris icon indicating copy to clipboard operation
doris copied to clipboard

[Bug] the built-in audit log plugin cannot pass stream load token check

Open ziyanTOP opened this issue 2 years ago • 1 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Version

2.1.0-rc11-91efb6a

What's Wrong?

the built-in audit log plugin will import audit log periodically through stream load, with token acquired from master. But when an non-master fe node submit audit log stream load, it submits to itself, and checkClusterToken() method will return false due to comparing two different token, one from master, the other from itself

2024-03-13 08:47:29,136 WARN (audit loader thread|60) [AuditStreamLoader.loadBatch():150] failed to load audit via AuditLoader plugin with label: audit_log_20240313_084729_127_0_0_1_18030
java.lang.Exception: status is not TEMPORARY_REDIRECT 307, status: 200, response: {"msg":"Unauthorized","code":401,"data":"Invalid token: 12c4cdbc-777f-40c2-92d0-60e2e65382de","count":0}, request is: curl -v -X PUT \
  -H "Authorization":"Basic " \
  -H "Expect":"100-continue" \
  -H "Content-Type":"text/plain; charset=UTF-8" \
  -H "max_filter_ratio":"1.0" \
  -H "columns":"query_id,time,client_ip,user,catalog,db,state,error_code,error_message,query_time,scan_bytes,scan_rows,return_rows,stmt_id,is_query,frontend_ip,cpu_time_ms,sql_hash,sql_digest,peak_memory_bytes,workload_group,stmt" \
  "http://127.0.0.1:18030/api/__internal_schema/audit_log/_stream_load?"
        at org.apache.doris.plugin.audit.AuditStreamLoader.loadBatch(AuditStreamLoader.java:124) ~[doris-fe.jar:1.2-SNAPSHOT]
        at org.apache.doris.plugin.audit.AuditLoaderPlugin.loadIfNecessary(AuditLoaderPlugin.java:214) ~[doris-fe.jar:1.2-SNAPSHOT]
        at org.apache.doris.plugin.audit.AuditLoaderPlugin.access$300(AuditLoaderPlugin.java:50) ~[doris-fe.jar:1.2-SNAPSHOT]
        at org.apache.doris.plugin.audit.AuditLoaderPlugin$LoadWorker.run(AuditLoaderPlugin.java:255) ~[doris-fe.jar:1.2-SNAPSHOT]
        at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_382]

code location: org.apache.doris.httpv2.rest.LoadAction

    private boolean checkClusterToken(String token) {
        return Env.getCurrentEnv().getLoadManager().getTokenManager().checkAuthToken(token);
    }

What You Expected?

non-master fe nodes submit audit log stream load to master, or use master token to compare when check stream load token

How to Reproduce?

send query to an non-master fe node, and check fe.log for code 401

Anything Else?

No response

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

ziyanTOP avatar Mar 13 '24 01:03 ziyanTOP

me too! I have the same problem!

ERROR.log: failed to load audit via AuditLoader plugin with label:
org.apache.doris.httpv2.exception.UnauthorizedException: Invalid token:

baofengzhouyu avatar Mar 13 '24 11:03 baofengzhouyu