Github user tillrohrmann commented on a diff in the pull request: https://github.com/apache/flink/pull/4281#discussion_r130037857 --- Diff: flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnEntrypointUtils.java --- @@ -0,0 +1,160 @@ +/* + * 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. + */ + +package org.apache.flink.yarn.entrypoint; + +import org.apache.flink.configuration.ConfigConstants; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.GlobalConfiguration; +import org.apache.flink.configuration.HighAvailabilityOptions; +import org.apache.flink.configuration.JobManagerOptions; +import org.apache.flink.configuration.SecurityOptions; +import org.apache.flink.runtime.clusterframework.BootstrapTools; +import org.apache.flink.runtime.security.SecurityContext; +import org.apache.flink.runtime.security.SecurityUtils; +import org.apache.flink.util.Preconditions; +import org.apache.flink.yarn.Utils; +import org.apache.flink.yarn.YarnConfigKeys; +import org.apache.flink.yarn.cli.FlinkYarnSessionCli; + +import org.apache.hadoop.fs.CommonConfigurationKeysPublic; +import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.yarn.api.ApplicationConstants; +import org.slf4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +/** + * This class contains utility methods for the {@link YarnSessionClusterEntrypoint} and + * {@link YarnJobClusterEntrypoint}. + */ +public class YarnEntrypointUtils { + + public static SecurityContext installSecurityContext( + Configuration configuration, + String workingDirectory) throws Exception { + org.apache.hadoop.conf.Configuration hadoopConfiguration = null; + + //To support Yarn Secure Integration Test Scenario + File krb5Conf = new File(workingDirectory, Utils.KRB5_FILE_NAME); + if (krb5Conf.exists() && krb5Conf.canRead()) { + hadoopConfiguration = new org.apache.hadoop.conf.Configuration(); + hadoopConfiguration.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos"); + hadoopConfiguration.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, "true"); + } + + SecurityUtils.SecurityConfiguration sc; + if (hadoopConfiguration != null) { + sc = new SecurityUtils.SecurityConfiguration(configuration, hadoopConfiguration); + } else { + sc = new SecurityUtils.SecurityConfiguration(configuration); + } + + SecurityUtils.install(sc); + + return SecurityUtils.getInstalledContext(); + } + + public static Configuration loadConfiguration(String workingDirectory, Map<String, String> env) { --- End diff -- Yes, this should be refactored. We should write the dynamic properties to the configuration file and make it available to the started YARN container. It's mainly due to historical reasons that we still send the dynamic properties encoded in an environment variable. Since this is an orthogonal issue, I would like to address this with a different PR. It is also related to: https://issues.apache.org/jira/browse/FLINK-7269
--- 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. ---