Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1342#discussion_r44390519
  
    --- Diff: flink-yarn/src/main/java/org/apache/flink/yarn/Utils.java ---
    @@ -135,7 +142,40 @@ public static void setTokensFor(ContainerLaunchContext 
amContainer, Path[] paths
                ByteBuffer securityTokens = ByteBuffer.wrap(dob.getData(), 0, 
dob.getLength());
                amContainer.setTokens(securityTokens);
        }
    -   
    +
    +   /**
    +    * Obtain Kerberos security token for HBase.
    +    */
    +   private static void obtainTokenForHBase(Credentials credentials, 
Configuration conf) {
    +           if (UserGroupInformation.isSecurityEnabled()) {
    +                   LOG.info("Attempting to obtain Kerberos security token 
for HBase");
    +                   try {
    +                           HBaseConfiguration.addHbaseResources(conf);
    +                           if 
(!"kerberos".equals(conf.get("hbase.security.authentication"))) {
    +                                   LOG.info("HBase has not been configured 
to use Kerberos.");
    +                                   return;
    +                           }
    +
    +                           LOG.info("Connecting to HBase");
    +                           Connection connection = 
ConnectionFactory.createConnection(conf);
    +
    +                           LOG.info("Obtaining Kerberos security token for 
HBase");
    +                           Token<AuthenticationTokenIdentifier> token = 
TokenUtil.obtainToken(connection);
    +
    +                           if (token == null) {
    +                                   LOG.error("No Kerberos security token 
for HBase available");
    +                                   return;
    +                           }
    +
    +                           credentials.addToken(token.getService(), token);
    +                           LOG.info("Added HBase Kerberos security token 
to credentials.");
    +                   } catch (IOException e) {
    +                           LOG.error("Caught exception while trying to 
obtain HBase Kerberos security token.");
    +                           e.printStackTrace();
    --- End diff --
    
    You might want to re`throw` the Exception here or not catch it at all. This 
ensures that it is probably forwarded to the client.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to