From 44f8b2a6304a99c451b1c79bb2638ff03a935145 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Wed, 11 Oct 2017 10:31:02 -0500 Subject: [PATCH] YARN-7082. TestContainerManagerSecurity failing in trunk. Contributed by Akira Ajisaka (cherry picked from commit ebb34c7053ee93296412591f83a776846765fda5) --- .../server/security/BaseContainerTokenSecretManager.java | 8 +++++--- .../yarn/server/ContainerTokenIdentifierForTest.java | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/security/BaseContainerTokenSecretManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/security/BaseContainerTokenSecretManager.java index a5590fbc1bd..420c899f686 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/security/BaseContainerTokenSecretManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/security/BaseContainerTokenSecretManager.java @@ -112,9 +112,11 @@ public class BaseContainerTokenSecretManager extends protected byte[] retrievePasswordInternal(ContainerTokenIdentifier identifier, MasterKeyData masterKey) throws org.apache.hadoop.security.token.SecretManager.InvalidToken { - LOG.debug("Retrieving password for {} for user {} to be run on NM {}", - identifier.getContainerID(), identifier.getUser(), - identifier.getNmHostAddress()); + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving password for {} for user {} to be run on NM {}", + identifier.getContainerID(), identifier.getUser(), + identifier.getNmHostAddress()); + } return createPassword(identifier.getBytes(), masterKey.getSecretKey()); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/ContainerTokenIdentifierForTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/ContainerTokenIdentifierForTest.java index 0d4d2e29b19..068b140e7e0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/ContainerTokenIdentifierForTest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/ContainerTokenIdentifierForTest.java @@ -24,6 +24,7 @@ import java.io.IOException; import org.apache.commons.io.IOUtils; import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.LogAggregationContext; import org.apache.hadoop.yarn.api.records.Priority; @@ -121,6 +122,12 @@ public class ContainerTokenIdentifierForTest extends ContainerTokenIdentifier { return new ContainerIdPBImpl(proto.getContainerId()); } + @Override + public UserGroupInformation getUser() { + final ContainerId containerId = getContainerID(); + return UserGroupInformation.createRemoteUser(containerId.toString()); + } + public String getApplicationSubmitter() { return proto.getAppSubmitter(); }