lcx412 opened a new pull request, #30025: URL: https://github.com/apache/flink/pull/30025
JIRA: https://issues.apache.org/jira/browse/FLINK-41435 ## What is the purpose of the change Hadoop delegation tokens are refreshed by DefaultDelegationTokenManager and delivered by HadoopDelegationTokenReceiver. The receiver currently adds refreshed credentials to UserGroupInformation.getCurrentUser() of the executing thread. That is not necessarily the UGI captured by long-lived Hadoop clients: a pooled thread can run with a Subject inherited from a different lifecycle, while the client remains bound to the UGI of the installed HadoopSecurityContext or the login user. In that case the refresh succeeds but the client keeps using its startup token and eventually fails at the 24h HDFS token deadline with SecretManager$InvalidToken. The issue can be triggered when the provider's HDFS RPC waits through Hadoop 3.5.0's CompletableFuture-based IPC path (HADOOP-19235) while freshUGI.doAs(...) is active; FJP compensation can then create workers that inherit the fresh Subject. The receiver-side fix is independent of that timing. Updating the current UGI would not address this case: the current UGI is the one that can be inherited from the unrelated lifecycle, while the long-lived client remains bound to the context/login UGI. ## Why this approach The receiver is the component that decides where refreshed credentials are stored, and it runs after the provider's freshUGI.doAs(...) scope has ended. Its getCurrentUser() therefore depends on whatever Subject the executing pool thread inherited, which is not a stable identifier for the client's UGI. The security-context UGI is the identity clients created through SecurityContext.runSecured() are bound to; the login UGI is the safe fallback when no Hadoop security context is installed. Provider-side getCurrentUser() calls are scoped by the acquisition freshUGI.doAs(...) and do not choose the delivery target. Changing the provider's doAs scope, the thread pool, or how threads inherit security contexts would be a broader behavioral change and would not remove this receiver-side assumption. ## Brief change log - Add HadoopSecurityContext#getHadoopUser(). - In HadoopDelegationTokenReceiver, select the security-context UGI when present, otherwise fall back to the login UGI. Do not use the executing thread's current UGI. - Add HadoopDelegationTokenReceiverTest covering context precedence, login fallback, non-targeting of the inherited current UGI, and existing validation behavior. ## Verifying this change This change added tests and can be verified as follows: - ./mvnw -pl flink-runtime -Dtest=HadoopDelegationTokenReceiverTest test - Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 - The tests assert that: - the security-context UGI receives the credentials and login/current are not updated; - the login UGI receives the credentials when no HadoopSecurityContext is installed, while current is not updated; - the existing overwrite and null/empty-token behavior is preserved. ## Does this pull request potentially affect one of the following parts: - Dependencies: no - The public API, i.e., is any changed class annotated with @Public(Evolving): no (HadoopSecurityContext is runtime-internal and is not annotated as public API) - The serializers: no - The runtime per-record code paths: no - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes (Hadoop delegation-token delivery for JobManager/TaskManager; no checkpoint format or recovery protocol change) - The S3 file system connector: no ## Documentation - Does this pull request introduce a new feature? no - If yes, how is the feature documented? not applicable; JavaDoc is added to the new accessor. -- 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]
