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-11198. clean up numa resources from statestore #4546

Merged
merged 3 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -231,7 +231,7 @@ public synchronized NumaResourceAllocation allocateNumaNodes(
}

private NumaResourceAllocation allocate(ContainerId containerId,
Resource resource) {
Resource resource) throws ResourceHandlerException {
for (int index = 0; index < numaNodesList.size(); index++) {
NumaNodeResource numaNode = numaNodesList
.get((currentAssignNode + index) % numaNodesList.size());
Expand Down Expand Up @@ -306,12 +306,20 @@ private NumaResourceAllocation allocate(ContainerId containerId,
* Release assigned NUMA resources for the container.
*
* @param containerId the container ID
* @throws ResourceHandlerException when failed to release numa resource
*/
public synchronized void releaseNumaResource(ContainerId containerId) {
public synchronized void releaseNumaResource(ContainerId containerId)
throws ResourceHandlerException {
LOG.info("Releasing the assigned NUMA resources for " + containerId);
for (NumaNodeResource numaNode : numaNodesList) {
numaNode.releaseResources(containerId);
}
// delete from NM State store
try {
context.getNMStateStore().releaseAssignedResources(containerId, NUMA_RESOURCE_TYPE);
} catch (IOException e){
throw new ResourceHandlerException(e);
}
}

/**
Expand Down
Expand Up @@ -1813,4 +1813,21 @@ protected void checkVersion() throws IOException {
+ getCurrentVersion() + ", but loading version " + loadedVersion);
}
}
@Override
public void releaseAssignedResources(ContainerId containerId, String resourceType)
throws IOException {
LOG.debug("releaseAssignedResources: containerId=" + containerId + " resourceType="
+ resourceType);
try {
try (WriteBatch batch = db.createWriteBatch()) {
String key = CONTAINERS_KEY_PREFIX + containerId
+ CONTAINER_ASSIGNED_RESOURCES_KEY_SUFFIX + resourceType;
batch.delete(bytes(key));
db.write(batch);
}
}catch (DBException e){
PrabhuJoseph marked this conversation as resolved.
Show resolved Hide resolved
markStoreUnHealthy(e);
throw new IOException(e);
}
}
}
Expand Up @@ -786,6 +786,15 @@ public abstract void storeAssignedResources(Container container,
String resourceType, List<Serializable> assignedResources)
throws IOException;

/**
* Delete the assigned resources of a container of specific resourceType.
* @param containerId Container Id
* @param resourceType resource Type
* @throws IOException while releasing resources
*/
public void releaseAssignedResources(ContainerId containerId, String resourceType)
throws IOException {}

protected abstract void initStorage(Configuration conf) throws IOException;

protected abstract void startStorage() throws IOException;
Expand Down
Expand Up @@ -1756,6 +1756,18 @@ public void testStateStoreForResourceMapping() throws IOException {
resources = rcs.getResourceMappings().getAssignedResources("numa");
Assert.assertEquals(numaRes, resources);
Assert.assertEquals(numaRes, resourceMappings.getAssignedResources("numa"));
// test removing numa resources from state store
stateStore.releaseAssignedResources(containerId, "numa");
recoveredContainers = loadContainersState(stateStore.getContainerStateIterator());
resourceMappings = recoveredContainers.get(0).getResourceMappings();
assertTrue(resourceMappings.getAssignedResources("numa").isEmpty());

// testing calling deletion of non-existing key doesn't break anything
try {
stateStore.releaseAssignedResources(containerId, "numa");
}catch (RuntimeException e){
Assert.fail("Should not throw exception while deleting non existing key from statestore");
}
}

@Test
Expand Down