jerqi commented on code in PR #9569:
URL: https://github.com/apache/gravitino/pull/9569#discussion_r2659511205
##########
catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/HDFSFileSystemProxy.java:
##########
@@ -148,46 +143,41 @@ public Object intercept(Object o, Method method, Object[]
objects, MethodProxy m
}
}
- /** Schedule periodic Kerberos re-login to refresh TGT before expiry. */
- private void startKerberosRenewalTask(String principal) {
- kerberosRenewExecutor =
- Executors.newSingleThreadScheduledExecutor(
- r -> {
- Thread t = new Thread(r, "HDFSFileSystemProxy
Kerberos-Renewal-Thread");
- t.setDaemon(true);
- return t;
- });
-
- kerberosRenewExecutor.scheduleAtFixedRate(
- () -> {
- try {
- if (ugi.hasKerberosCredentials()) {
- ugi.checkTGTAndReloginFromKeytab();
- }
- } catch (Exception e) {
- LOG.error(
- "[Kerberos] Failed to renew TGT for principal {}: {}",
- principal,
- e.getMessage(),
- e);
- }
- },
- DEFAULT_RENEW_INTERVAL_MS,
- DEFAULT_RENEW_INTERVAL_MS,
- TimeUnit.MILLISECONDS);
+ @SuppressWarnings("removal")
+ public static Principal getCurrentPrincipal() {
+ java.security.AccessControlContext context =
java.security.AccessController.getContext();
+ Subject subject = Subject.getSubject(context);
+ if (subject == null ||
subject.getPrincipals(UserPrincipal.class).isEmpty()) {
+ return null;
+ }
+ return subject.getPrincipals(UserPrincipal.class).iterator().next();
}
- /** Close the Kerberos renewal executor service to prevent resource leaks. */
- private void close() {
- if (kerberosRenewExecutor != null) {
- kerberosRenewExecutor.shutdownNow();
- kerberosRenewExecutor = null;
+ private UserGroupInformation getCurrentUgi() throws Exception {
+ UserGroupInformation currentUgi = UserGroupInformation.getLoginUser();
Review Comment:
LoginUser isn't equal to current user.
--
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]