YARN-11278. Fixed Ambiguous error message in mutation API. Contributed by Ashutosh Gupta.

This commit is contained in:
9uapaw 2022-09-09 14:38:41 +02:00
parent 56387cce57
commit 5b85af87f0

View File

@ -2748,26 +2748,26 @@ public synchronized Response updateSchedulerConfiguration(SchedConfUpdateInfo
initForWritableEndpoints(callerUGI, true);
ResourceScheduler scheduler = rm.getResourceScheduler();
if (isConfigurationMutable(scheduler)) {
if (!(scheduler instanceof MutableConfScheduler)) {
return Response.status(Status.BAD_REQUEST)
.entity("Configuration change only supported by MutableConfScheduler.").build();
} else if (!((MutableConfScheduler) scheduler).isConfigurationMutable()) {
return Response.status(Status.BAD_REQUEST)
.entity("Configuration change only supported by mutable configuration store.").build();
} else {
try {
callerUGI.doAs((PrivilegedExceptionAction<Void>) () -> {
MutableConfigurationProvider provider = ((MutableConfScheduler)
scheduler).getMutableConfProvider();
MutableConfigurationProvider provider =
((MutableConfScheduler) scheduler).getMutableConfProvider();
LogMutation logMutation = applyMutation(provider, callerUGI, mutationInfo);
return refreshQueues(provider, logMutation);
});
} catch (IOException e) {
LOG.error("Exception thrown when modifying configuration.", e);
return Response.status(Status.BAD_REQUEST).entity(e.getMessage())
.build();
return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build();
}
return Response.status(Status.OK).entity("Configuration change successfully applied.")
.build();
} else {
return Response.status(Status.BAD_REQUEST)
.entity(String.format("Configuration change only supported by " +
"%s.", MutableConfScheduler.class.getSimpleName()))
.build();
}
}