You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by fc...@apache.org on 2024/10/15 13:38:32 UTC

(flink) branch release-1.20 updated: [FLINK-36405][runtime] Fix startup issues due to Hive delegation token on kerberos clusters

This is an automated email from the ASF dual-hosted git repository.

fcsaky pushed a commit to branch release-1.20
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.20 by this push:
     new 5a548168bab [FLINK-36405][runtime] Fix startup issues due to Hive delegation token on kerberos clusters
5a548168bab is described below

commit 5a548168bab54fc18594674077a46be214d688ba
Author: zhengchenyu <zh...@163.com>
AuthorDate: Tue Oct 15 21:38:23 2024 +0800

    [FLINK-36405][runtime] Fix startup issues due to Hive delegation token on kerberos clusters
    
    Co-authored-by: zhengchenyu001 <zh...@ke.com>
---
 .../token/HiveServer2DelegationTokenProvider.java        | 11 +++--------
 .../org.apache.hadoop.security.token.TokenIdentifier     | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/security/token/HiveServer2DelegationTokenProvider.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/security/token/HiveServer2DelegationTokenProvider.java
index 2988f2aebd6..70a04863a74 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/security/token/HiveServer2DelegationTokenProvider.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/security/token/HiveServer2DelegationTokenProvider.java
@@ -136,14 +136,9 @@ public class HiveServer2DelegationTokenProvider implements DelegationTokenProvid
                             try {
                                 LOG.info("Obtaining Kerberos security token for HiveServer2");
 
-                                String principal =
-                                        hiveConf.getTrimmed(
-                                                "hive.metastore.kerberos.principal", "");
-
-                                String tokenStr =
-                                        hive.getDelegationToken(
-                                                UserGroupInformation.getCurrentUser().getUserName(),
-                                                principal);
+                                String user = UserGroupInformation.getCurrentUser().getUserName();
+                                String tokenStr = hive.getDelegationToken(user, user);
+
                                 Token<HiveServer2DelegationTokenIdentifier> hive2Token =
                                         new Token<>();
                                 hive2Token.decodeFromUrlString(tokenStr);
diff --git a/flink-connectors/flink-connector-hive/src/main/resources/META-INF/services/org.apache.hadoop.security.token.TokenIdentifier b/flink-connectors/flink-connector-hive/src/main/resources/META-INF/services/org.apache.hadoop.security.token.TokenIdentifier
new file mode 100644
index 00000000000..0fd7c83c632
--- /dev/null
+++ b/flink-connectors/flink-connector-hive/src/main/resources/META-INF/services/org.apache.hadoop.security.token.TokenIdentifier
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.flink.table.security.token.HiveServer2DelegationTokenIdentifier