YARN-9790. Failed to set default-application-lifetime if maximum-application-lifetime is less than or equal to zero. Contributed by kyungwan nam.

This commit is contained in:
Abhishek Modi 2019-09-01 09:54:46 +05:30
parent c187d2cb9f
commit d2d963f3d4
3 changed files with 20 additions and 5 deletions

View File

@ -3116,7 +3116,8 @@ public long checkAndGetApplicationLifetime(String queueName,
// check only for maximum, that's enough because default can't
// exceed maximum
if (maximumApplicationLifetime <= 0) {
return lifetimeRequestedByApp;
return (lifetimeRequestedByApp <= 0) ? defaultApplicationLifetime :
lifetimeRequestedByApp;
}
if (lifetimeRequestedByApp <= 0) {

View File

@ -259,7 +259,8 @@ protected void setupQueueConfigs(Resource clusterResource,
conf.getMaximumLifetimePerQueue((getQueuePath()));
defaultApplicationLifetime =
conf.getDefaultLifetimePerQueue((getQueuePath()));
if (defaultApplicationLifetime > maxApplicationLifetime) {
if (maxApplicationLifetime > 0 &&
defaultApplicationLifetime > maxApplicationLifetime) {
throw new YarnRuntimeException(
"Default lifetime" + defaultApplicationLifetime
+ " can't exceed maximum lifetime " + maxApplicationLifetime);

View File

@ -5171,7 +5171,8 @@ public void testcheckAndGetApplicationLifetime() throws Exception {
Assert.assertEquals(100, cs.checkAndGetApplicationLifetime("default", 100));
Assert.assertEquals(defaultLifetime,
cs.checkAndGetApplicationLifetime("default", -1));
Assert.assertEquals(0, cs.checkAndGetApplicationLifetime("default", 0));
Assert.assertEquals(defaultLifetime,
cs.checkAndGetApplicationLifetime("default", 0));
Assert.assertEquals(maxLifetime,
cs.getMaximumApplicationLifetime("default"));
@ -5191,8 +5192,10 @@ public void testcheckAndGetApplicationLifetime() throws Exception {
defaultLifetime = 0;
cs = setUpCSQueue(maxLifetime, defaultLifetime);
Assert.assertEquals(100, cs.checkAndGetApplicationLifetime("default", 100));
Assert.assertEquals(-1, cs.checkAndGetApplicationLifetime("default", -1));
Assert.assertEquals(0, cs.checkAndGetApplicationLifetime("default", 0));
Assert.assertEquals(defaultLifetime,
cs.checkAndGetApplicationLifetime("default", -1));
Assert.assertEquals(defaultLifetime,
cs.checkAndGetApplicationLifetime("default", 0));
maxLifetime = 10;
defaultLifetime = -1;
@ -5213,6 +5216,16 @@ public void testcheckAndGetApplicationLifetime() throws Exception {
Assert.assertTrue(
ye.getMessage().contains("can't exceed maximum lifetime"));
}
maxLifetime = -1;
defaultLifetime = 10;
cs = setUpCSQueue(maxLifetime, defaultLifetime);
Assert.assertEquals(100,
cs.checkAndGetApplicationLifetime("default", 100));
Assert.assertEquals(defaultLifetime,
cs.checkAndGetApplicationLifetime("default", -1));
Assert.assertEquals(defaultLifetime,
cs.checkAndGetApplicationLifetime("default", 0));
}
private CapacityScheduler setUpCSQueue(long maxLifetime,