CalvinKirs opened a new pull request, #64394:
URL: https://github.com/apache/doris/pull/64394

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #62023
   
   Problem Summary:
   
   The regression case `test_two_hive_kerberos` fails intermittently with:
   
   ```
   GSSException: No valid credentials provided
     ...
   Caused by: javax.security.auth.login.LoginException: Cannot read from 
System.in
   ```
   
   Root cause: the `KerberosHadoopAuthenticator` in `fe-filesystem-hdfs` 
(introduced in #62023) relies on Hadoop's 
`UserGroupInformation.checkTGTAndReloginFromKeytab()`, which has a hard-coded 
60s relogin throttle (`hasSufficientTimeElapsed`). When the TGT expires inside 
that throttle window, the relogin is silently skipped, the subsequent SASL 
handshake finds no valid ticket, and the JAAS fallback path tries to prompt on 
`System.in` — which fails in a server process.
   
   Fix: replace the throttled reactive relogin with trino's proactive TGT 
refresh model (ported 1:1 from trino 435 `KerberosAuthentication` / 
`CachingKerberosHadoopAuthentication` / `KerberosTicketUtils`):
   
   - Login eagerly at construction with explicit JAAS options 
(`doNotPrompt=true`, `useKeyTab=true`, `storeKey=true`, `isInitiator=true`) — 
`doNotPrompt=true` makes the `System.in` prompt path impossible.
   - Compute the next refresh time as ticket start + 80% of ticket lifetime.
   - On each `doAs`, if past the refresh point, perform a fresh keytab login 
(no throttle) and swap the new credentials into the existing `Subject` in 
place, so the cached UGI stays valid.
   - A failed refresh does not advance the refresh time, so the next call 
retries immediately; the failure is wrapped as `IOException` to keep the SPI's 
checked-exception contract.
   
   The vendored `KerberosTicketUtils` is placed in `fe-foundation` 
(`org.apache.doris.foundation.security`) and provided to filesystem plugins 
through `fe-filesystem-spi`, which also lets `fe-common`'s 
`HadoopKerberosAuthenticator` drop its `io.trino` import.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. <!-- Explain the behavior change --> Kerberos keytab relogin 
in fe-filesystem-hdfs is now proactive (refresh at 80% of TGT lifetime, 
unthrottled) instead of Hadoop's reactive relogin with a 60s throttle.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to