Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YARN-11708: Setting maximum-application-lifetime using AQCv2 template… #7041

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3364,12 +3364,32 @@ public boolean moveReservedContainer(RMContainer toBeMovedContainer,
}
}

@Override
@Override
public long checkAndGetApplicationLifetime(String queueName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of add this create new queue logic to the method we could make the getOrCreateQueueFromPlacementContext public and call it before we call the checkAndGetApplicationLifetime method. If i see well this checkAndGetApplicationLifetime used just once in the code

long lifetimeRequestedByApp) {
CSQueue queue;

writeLock.lock();
try {
queue = getQueue(queueName);

// This handles the case where the queue does not exist,
// addressing the issue related to YARN-11708.
if (queue == null) {
QueuePath queuePath = new QueuePath(queueName);
try {
queue = queueManager.createQueue(queuePath);
} catch (YarnException | IOException e) {
LOG.error("Failed to create queue " + queueName, e);
throw new YarnRuntimeException("Queue creation failed", e);
}
}
} finally {
writeLock.unlock();
}

readLock.lock();
try {
CSQueue queue = getQueue(queueName);
if (!(queue instanceof AbstractLeafQueue)) {
return lifetimeRequestedByApp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,61 @@ public void testAutoQueueCreationFailsForEmptyPathWithAQCAndWeightMode()
}
}

@Test
public void testAutoQueueCreationWithWeightModeAndMaxAppLifetimeFirstSubmittedApp()
throws Exception {
if (mockRM != null) {
mockRM.stop();
}

long maxRootLifetime = 20L;
long defaultRootLifetime = 10L;

QueuePath TEST_QUEUE = new QueuePath("root.test");

CapacitySchedulerConfiguration conf = setupSchedulerConfiguration();
conf.setQueues(ROOT, new String[] {"test"});
conf.setAutoQueueCreationV2Enabled(TEST_QUEUE, true);
conf.setCapacity(DEFAULT, "1w");
conf.setCapacity(TEST_QUEUE, "2w");
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
ResourceScheduler.class);

conf.setMaximumLifetimePerQueue(ROOT, maxRootLifetime);
conf.setDefaultLifetimePerQueue(ROOT, defaultRootLifetime);

MockRM newMockRM = new MockRM(conf);
newMockRM.start();
((CapacityScheduler) newMockRM.getResourceScheduler()).start();

CapacityScheduler newCS =
(CapacityScheduler) newMockRM.getResourceScheduler();
newCS.checkAndGetApplicationLifetime("root.test.user", -1);

Assert.assertEquals(newCS.getMaximumApplicationLifetime("root.test.user"), 20L);

try {
Priority appPriority = Priority.newInstance(0);
RMApp app1 = MockRMAppSubmitter.submit(newMockRM,
MockRMAppSubmissionData.Builder.createWithMemory(1024, newMockRM)
.withAppPriority(appPriority)
.withQueue("root.test.user")
.build());

newMockRM.waitForState(app1.getApplicationId(), RMAppState.KILLED);
long totalTimeRun = app1.getFinishTime() - app1.getSubmitTime();

Assert.assertEquals(RMAppState.KILLED, app1.getState());
Assert.assertTrue("Application killed before default lifetime value",
totalTimeRun > (defaultRootLifetime * 1000));
Assert.assertTrue(
"Application killed after max lifetime value " + totalTimeRun,
totalTimeRun < (maxRootLifetime * 1000));
} finally {
((CapacityScheduler) newMockRM.getResourceScheduler()).stop();
newMockRM.stop();
}
}

/**
* This test case checks if a mapping rule can put an application to an auto
Expand Down
Loading