use of com.yahoo.vespa.orchestrator.policy.BatchHostStateChangeDeniedException in project vespa by vespa-engine.
the class OrchestratorImplTest method whenSuspendAllFails.
@Test
public void whenSuspendAllFails() throws Exception {
// A spy is preferential because suspendAll() relies on delegating the hard work to suspend() and resume().
OrchestratorImpl orchestrator = spy(this.orchestrator);
Throwable supensionFailure = new HostStateChangeDeniedException(DummyInstanceLookupService.TEST6_HOST_NAME, "some-constraint", "error message");
doThrow(supensionFailure).when(orchestrator).suspendGroup(DummyInstanceLookupService.TEST6_NODE_GROUP);
try {
orchestrator.suspendAll(new HostName("parentHostname"), Arrays.asList(DummyInstanceLookupService.TEST1_HOST_NAME, DummyInstanceLookupService.TEST3_HOST_NAME, DummyInstanceLookupService.TEST6_HOST_NAME));
fail();
} catch (BatchHostStateChangeDeniedException e) {
assertEquals("Failed to suspend NodeGroup{application=tenant-id-3:application-instance-3:prod:utopia-1:default, " + "hostNames=[test6.hostname.tld]} with parent host parentHostname: " + "Changing the state of test6.hostname.tld would violate " + "some-constraint: error message", e.getMessage());
}
InOrder order = inOrder(orchestrator);
order.verify(orchestrator).suspendGroup(DummyInstanceLookupService.TEST3_NODE_GROUP);
order.verify(orchestrator).suspendGroup(DummyInstanceLookupService.TEST6_NODE_GROUP);
order.verifyNoMoreInteractions();
}
use of com.yahoo.vespa.orchestrator.policy.BatchHostStateChangeDeniedException in project vespa by vespa-engine.
the class HostSuspensionResource method suspendAll.
@Override
public BatchOperationResult suspendAll(String parentHostnameString, List<String> hostnamesAsStrings) {
HostName parentHostname = new HostName(parentHostnameString);
List<HostName> hostnames = hostnamesAsStrings.stream().map(HostName::new).collect(Collectors.toList());
try {
orchestrator.suspendAll(parentHostname, hostnames);
} catch (BatchHostStateChangeDeniedException e) {
log.log(LogLevel.DEBUG, "Failed to suspend nodes " + hostnames + " with parent host " + parentHostname, e);
throw createWebApplicationException(e.getMessage(), Response.Status.CONFLICT);
} catch (BatchHostNameNotFoundException e) {
log.log(LogLevel.DEBUG, "Failed to suspend nodes " + hostnames + " with parent host " + parentHostname, e);
// by the URL path was found. It's one of the hostnames in the request it failed to find.
throw createWebApplicationException(e.getMessage(), Response.Status.BAD_REQUEST);
} catch (BatchInternalErrorException e) {
log.log(LogLevel.DEBUG, "Failed to suspend nodes " + hostnames + " with parent host " + parentHostname, e);
throw createWebApplicationException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
}
log.log(LogLevel.DEBUG, "Suspended " + hostnames + " with parent " + parentHostname);
return BatchOperationResult.successResult();
}
Aggregations