Skip to content

Commit

Permalink
Merge pull request #14 from pdtran3k6/LIHADOOP-40358
Browse files Browse the repository at this point in the history
LIHADOOP-40358: Changed security constant's name
  • Loading branch information
oliverhu committed Sep 19, 2018
2 parents 0631859 + 5f71bea commit 043dfed
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public class TonyApplicationMaster {
// Cluster spec
private ApplicationRpcServer rpcServer;

// Local mode
private boolean insecureMode;
// Set to false when testing locally / running in insecure cluster
private boolean secureMode;

// Single node training
private boolean singleNode;
Expand Down Expand Up @@ -251,8 +251,8 @@ private boolean init(String[] args) {
TonyConfigurationKeys.DEFAULT_AM_RETRY_COUNT);
singleNode = tonyConf.getBoolean(TonyConfigurationKeys.IS_SINGLE_NODE,
TonyConfigurationKeys.DEFAULT_IS_SINGLE_NODE);
insecureMode = tonyConf.getBoolean(TonyConfigurationKeys.IS_INSECURE_MODE,
TonyConfigurationKeys.DEFAULT_IS_INSECURE_MODE);
secureMode = tonyConf.getBoolean(TonyConfigurationKeys.SECURITY_ENABLED,
TonyConfigurationKeys.DEFAULT_SECURITY_ENABLED);
enablePreprocessing = tonyConf.getBoolean(TonyConfigurationKeys.ENABLE_PREPROCESSING_JOB,
TonyConfigurationKeys.DEFAULT_ENABLE_PREPROCESSING_JOB);
ContainerId containerId = ContainerId.fromString(envs.get(ApplicationConstants.Environment.CONTAINER_ID.name()));
Expand Down Expand Up @@ -393,7 +393,7 @@ private boolean prepare() {
response = amRMClient.registerApplicationMaster(hostname, amPort, null);
amHostPort = hostname + ":" + amPort;
LOG.info("RPC server running at: " + amHostPort);
if (!insecureMode) {
if (secureMode) {
ClientToAMTokenIdentifier identifier =
new ClientToAMTokenIdentifier(appAttemptID, UserGroupInformation.getCurrentUser().getShortUserName());
byte[] secret = response.getClientToAMTokenMasterKey().array();
Expand Down Expand Up @@ -1056,7 +1056,7 @@ public void run() {
acls.put(ApplicationAccessType.MODIFY_APP, " ");

ByteBuffer tokens = null;
if (!insecureMode) {
if (secureMode) {
tokens = allTokens.duplicate();
}
ContainerLaunchContext ctx = ContainerLaunchContext.newInstance(new ConcurrentHashMap<>(localResources),
Expand Down
8 changes: 4 additions & 4 deletions tony-core/src/main/java/com/linkedin/tony/TonyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class TonyClient {
private String pythonVenv = "";
private String executes;
private long appTimeout;
private boolean insecureMode;
private boolean secureMode;
private String srcDir;
private Map<String, String> shellEnv = new HashMap<>();
private Map<String, String> containerEnv = new HashMap<>();
Expand Down Expand Up @@ -261,8 +261,8 @@ private boolean init(String[] args) throws ParseException {
TonyConfigurationKeys.DEFAULT_AM_VCORES);
amGpus = tonyConf.getInt(TonyConfigurationKeys.AM_GPUS,
TonyConfigurationKeys.DEFAULT_AM_GPUS);
insecureMode = tonyConf.getBoolean(TonyConfigurationKeys.IS_INSECURE_MODE,
TonyConfigurationKeys.DEFAULT_IS_INSECURE_MODE);
secureMode = tonyConf.getBoolean(TonyConfigurationKeys.SECURITY_ENABLED,
TonyConfigurationKeys.DEFAULT_SECURITY_ENABLED);
hbInterval = tonyConf.getInt(TonyConfigurationKeys.TASK_HEARTBEAT_INTERVAL_MS,
TonyConfigurationKeys.DEFAULT_TASK_HEARTBEAT_INTERVAL_MS);
maxHbMisses = tonyConf.getInt(TonyConfigurationKeys.TASK_MAX_MISSED_HEARTBEATS,
Expand Down Expand Up @@ -545,7 +545,7 @@ private void setAMEnvironment(Map<String, LocalResource> localResources,

// Set up delegation token
private ByteBuffer getTokens() throws IOException, URISyntaxException, YarnException {
if (this.insecureMode) {
if (!this.secureMode) {
return null;
}
Credentials cred = new Credentials();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private TonyConfigurationKeys() {
public static final int DEFAULT_WORKER_INSTANCES = 1;

// Local testing configurations
public static final String IS_INSECURE_MODE = TONY_APPLICATION_PREFIX + "insecure-mode";
public static final boolean DEFAULT_IS_INSECURE_MODE = false;
public static final String SECURITY_ENABLED = TONY_APPLICATION_PREFIX + "security.enabled";
public static final boolean DEFAULT_SECURITY_ENABLED = true;

public static final String HDFS_CONF_LOCATION = TONY_APPLICATION_PREFIX + "hdfs-conf-path";

Expand Down
4 changes: 2 additions & 2 deletions tony-core/src/main/resources/tony-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@
Whether this application is running in a Kerberized grid. Enabling this will fetch tokens from the cluster as
well as between the client and AM.
</description>
<name>tony.application.insecure-mode</name>
<value>false</value>
<name>tony.application.security.enabled</name>
<value>true</value>
</property>

<property>
Expand Down
18 changes: 9 additions & 9 deletions tony-core/src/test/java/com/linkedin/tony/TestTonyE2E.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void tearDown() {
public void testSingleNodeTrainingShouldPass() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_SINGLE_NODE, true);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
int exitCode = TonyClient.start(new String[] {
Expand All @@ -73,7 +73,7 @@ public void testSingleNodeTrainingShouldPass() {
@Test
public void testPSWorkerTrainingShouldFailMissedHeartbeat() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
conf.setInt(TonyConfigurationKeys.TASK_MAX_MISSED_HEARTBEATS, 2);
Expand All @@ -91,7 +91,7 @@ public void testPSWorkerTrainingShouldFailMissedHeartbeat() {
@Test
public void testPSSkewedWorkerTrainingShouldPass() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
conf.setInt(TonyConfigurationKeys.WORKER_INSTANCES, 2);
Expand All @@ -110,7 +110,7 @@ public void testPSSkewedWorkerTrainingShouldPass() {
@Test
public void testPSWorkerTrainingShouldPass() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
int exitCode = TonyClient.start(new String[]{
Expand All @@ -127,7 +127,7 @@ public void testPSWorkerTrainingShouldPass() {
@Test
public void testPSWorkerTrainingShouldFail() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
int exitCode = TonyClient.start(new String[]{
Expand All @@ -144,7 +144,7 @@ public void testPSWorkerTrainingShouldFail() {
public void testSingleNodeTrainingShouldFail() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_SINGLE_NODE, true);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
int exitCode = TonyClient.start(new String[]{
Expand All @@ -161,7 +161,7 @@ public void testSingleNodeTrainingShouldFail() {
public void testAMCrashTonyShouldFail() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_SINGLE_NODE, true);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
int exitCode = TonyClient.start(new String[]{
Expand All @@ -182,7 +182,7 @@ public void testAMCrashTonyShouldFail() {
@Test(enabled = false)
public void testAMRequestsNewContainersAfterTimeout() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
conf.setInt(TonyConfigurationKeys.PS_INSTANCES, 2);
Expand All @@ -207,7 +207,7 @@ public void testAMRequestsNewContainersAfterTimeout() {
@Test
public void testAMStopsJobAfterTimeout() {
Configuration conf = new Configuration(false);
conf.setBoolean(TonyConfigurationKeys.IS_INSECURE_MODE, true);
conf.setBoolean(TonyConfigurationKeys.SECURITY_ENABLED, false);
conf.set(TonyConfigurationKeys.HDFS_CONF_LOCATION, hdfsConf);
conf.set(TonyConfigurationKeys.YARN_CONF_LOCATION, yarnConf);
conf.setInt(TonyConfigurationKeys.TASK_REGISTRATION_TIMEOUT_SEC, 5);
Expand Down

0 comments on commit 043dfed

Please sign in to comment.