YARN-2065 AM cannot create new containers after restart
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1607441 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c89bf0184d
commit
d1f54f4f4b
|
@ -322,6 +322,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
YARN-2201. Made TestRMWebServicesAppsModification be independent of the
|
YARN-2201. Made TestRMWebServicesAppsModification be independent of the
|
||||||
changes on yarn-default.xml. (Varun Vasudev via zjshen)
|
changes on yarn-default.xml. (Varun Vasudev via zjshen)
|
||||||
|
|
||||||
|
YARN-2216 YARN-2065 AM cannot create new containers after restart
|
||||||
|
(Jian He via stevel)
|
||||||
|
|
||||||
Release 2.4.1 - 2014-06-23
|
Release 2.4.1 - 2014-06-23
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -475,8 +475,8 @@ public class ContainerManagerImpl extends CompositeService implements
|
||||||
boolean unauthorized = false;
|
boolean unauthorized = false;
|
||||||
StringBuilder messageBuilder =
|
StringBuilder messageBuilder =
|
||||||
new StringBuilder("Unauthorized request to start container. ");
|
new StringBuilder("Unauthorized request to start container. ");
|
||||||
if (!nmTokenIdentifier.getApplicationAttemptId().equals(
|
if (!nmTokenIdentifier.getApplicationAttemptId().getApplicationId().equals(
|
||||||
containerId.getApplicationAttemptId())) {
|
containerId.getApplicationAttemptId().getApplicationId())) {
|
||||||
unauthorized = true;
|
unauthorized = true;
|
||||||
messageBuilder.append("\nNMToken for application attempt : ")
|
messageBuilder.append("\nNMToken for application attempt : ")
|
||||||
.append(nmTokenIdentifier.getApplicationAttemptId())
|
.append(nmTokenIdentifier.getApplicationAttemptId())
|
||||||
|
@ -810,26 +810,24 @@ public class ContainerManagerImpl extends CompositeService implements
|
||||||
* belongs to the same application attempt (NMToken) which was used. (Note:-
|
* belongs to the same application attempt (NMToken) which was used. (Note:-
|
||||||
* This will prevent user in knowing another application's containers).
|
* This will prevent user in knowing another application's containers).
|
||||||
*/
|
*/
|
||||||
|
ApplicationId nmTokenAppId =
|
||||||
if ((!identifier.getApplicationAttemptId().equals(
|
identifier.getApplicationAttemptId().getApplicationId();
|
||||||
containerId.getApplicationAttemptId()))
|
if ((!nmTokenAppId.equals(containerId.getApplicationAttemptId().getApplicationId()))
|
||||||
|| (container != null && !identifier.getApplicationAttemptId().equals(
|
|| (container != null && !nmTokenAppId.equals(container
|
||||||
container.getContainerId().getApplicationAttemptId()))) {
|
.getContainerId().getApplicationAttemptId().getApplicationId()))) {
|
||||||
if (stopRequest) {
|
if (stopRequest) {
|
||||||
LOG.warn(identifier.getApplicationAttemptId()
|
LOG.warn(identifier.getApplicationAttemptId()
|
||||||
+ " attempted to stop non-application container : "
|
+ " attempted to stop non-application container : "
|
||||||
+ container.getContainerId().toString());
|
+ container.getContainerId());
|
||||||
NMAuditLogger.logFailure("UnknownUser", AuditConstants.STOP_CONTAINER,
|
NMAuditLogger.logFailure("UnknownUser", AuditConstants.STOP_CONTAINER,
|
||||||
"ContainerManagerImpl", "Trying to stop unknown container!",
|
"ContainerManagerImpl", "Trying to stop unknown container!",
|
||||||
identifier.getApplicationAttemptId().getApplicationId(),
|
nmTokenAppId, container.getContainerId());
|
||||||
container.getContainerId());
|
|
||||||
} else {
|
} else {
|
||||||
LOG.warn(identifier.getApplicationAttemptId()
|
LOG.warn(identifier.getApplicationAttemptId()
|
||||||
+ " attempted to get status for non-application container : "
|
+ " attempted to get status for non-application container : "
|
||||||
+ container.getContainerId().toString());
|
+ container.getContainerId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContainerEventDispatcher implements EventHandler<ContainerEvent> {
|
class ContainerEventDispatcher implements EventHandler<ContainerEvent> {
|
||||||
|
|
|
@ -202,8 +202,6 @@ public class TestContainerManagerSecurity extends KerberosSecurityTestcase {
|
||||||
ApplicationId appId = ApplicationId.newInstance(1, 1);
|
ApplicationId appId = ApplicationId.newInstance(1, 1);
|
||||||
ApplicationAttemptId validAppAttemptId =
|
ApplicationAttemptId validAppAttemptId =
|
||||||
ApplicationAttemptId.newInstance(appId, 1);
|
ApplicationAttemptId.newInstance(appId, 1);
|
||||||
ApplicationAttemptId invalidAppAttemptId =
|
|
||||||
ApplicationAttemptId.newInstance(appId, 2);
|
|
||||||
|
|
||||||
ContainerId validContainerId =
|
ContainerId validContainerId =
|
||||||
ContainerId.newInstance(validAppAttemptId, 0);
|
ContainerId.newInstance(validAppAttemptId, 0);
|
||||||
|
@ -269,26 +267,14 @@ public class TestContainerManagerSecurity extends KerberosSecurityTestcase {
|
||||||
testStartContainer(rpc, validAppAttemptId, validNode,
|
testStartContainer(rpc, validAppAttemptId, validNode,
|
||||||
validContainerToken, invalidNMToken, true)));
|
validContainerToken, invalidNMToken, true)));
|
||||||
|
|
||||||
// using appAttempt-2 token for launching container for appAttempt-1.
|
|
||||||
invalidNMToken =
|
|
||||||
nmTokenSecretManagerRM.createNMToken(invalidAppAttemptId, validNode,
|
|
||||||
user);
|
|
||||||
sb = new StringBuilder("\nNMToken for application attempt : ");
|
|
||||||
sb.append(invalidAppAttemptId.toString())
|
|
||||||
.append(" was used for starting container with container token")
|
|
||||||
.append(" issued for application attempt : ")
|
|
||||||
.append(validAppAttemptId.toString());
|
|
||||||
Assert.assertTrue(testStartContainer(rpc, validAppAttemptId, validNode,
|
|
||||||
validContainerToken, invalidNMToken, true).contains(sb.toString()));
|
|
||||||
|
|
||||||
// using correct tokens. nmtoken for app attempt should get saved.
|
// using correct tokens. nmtoken for app attempt should get saved.
|
||||||
conf.setInt(YarnConfiguration.RM_CONTAINER_ALLOC_EXPIRY_INTERVAL_MS,
|
conf.setInt(YarnConfiguration.RM_CONTAINER_ALLOC_EXPIRY_INTERVAL_MS,
|
||||||
4 * 60 * 1000);
|
4 * 60 * 1000);
|
||||||
validContainerToken =
|
validContainerToken =
|
||||||
containerTokenSecretManager.createContainerToken(validContainerId,
|
containerTokenSecretManager.createContainerToken(validContainerId,
|
||||||
validNode, user, r, Priority.newInstance(0), 0);
|
validNode, user, r, Priority.newInstance(0), 0);
|
||||||
testStartContainer(rpc, validAppAttemptId, validNode, validContainerToken,
|
Assert.assertTrue(testStartContainer(rpc, validAppAttemptId, validNode,
|
||||||
validNMToken, false);
|
validContainerToken, validNMToken, false).isEmpty());
|
||||||
Assert.assertTrue(nmTokenSecretManagerNM
|
Assert.assertTrue(nmTokenSecretManagerNM
|
||||||
.isAppAttemptNMTokenKeyPresent(validAppAttemptId));
|
.isAppAttemptNMTokenKeyPresent(validAppAttemptId));
|
||||||
|
|
||||||
|
@ -330,6 +316,18 @@ public class TestContainerManagerSecurity extends KerberosSecurityTestcase {
|
||||||
Assert.assertTrue(testGetContainer(rpc, validAppAttemptId, validNode,
|
Assert.assertTrue(testGetContainer(rpc, validAppAttemptId, validNode,
|
||||||
validContainerId, validNMToken, false).contains(sb.toString()));
|
validContainerId, validNMToken, false).contains(sb.toString()));
|
||||||
|
|
||||||
|
// using appAttempt-1 NMtoken for launching container for appAttempt-2 should
|
||||||
|
// succeed.
|
||||||
|
ApplicationAttemptId attempt2 = ApplicationAttemptId.newInstance(appId, 2);
|
||||||
|
Token attempt1NMToken =
|
||||||
|
nmTokenSecretManagerRM
|
||||||
|
.createNMToken(validAppAttemptId, validNode, user);
|
||||||
|
org.apache.hadoop.yarn.api.records.Token newContainerToken =
|
||||||
|
containerTokenSecretManager.createContainerToken(
|
||||||
|
ContainerId.newInstance(attempt2, 1), validNode, user, r,
|
||||||
|
Priority.newInstance(0), 0);
|
||||||
|
Assert.assertTrue(testStartContainer(rpc, attempt2, validNode,
|
||||||
|
newContainerToken, attempt1NMToken, false).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForContainerToFinishOnNM(ContainerId containerId) {
|
private void waitForContainerToFinishOnNM(ContainerId containerId) {
|
||||||
|
|
Loading…
Reference in New Issue