use of com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus in project vespa by vespa-engine.
the class HostedVespaPolicy method acquirePermissionToRemove.
@Override
public void acquirePermissionToRemove(ApplicationApi applicationApi) throws HostStateChangeDeniedException {
ApplicationInstanceStatus applicationStatus = applicationApi.getApplicationStatus();
if (applicationStatus == ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN) {
throw new HostStateChangeDeniedException(applicationApi.getNodeGroup(), HostedVespaPolicy.APPLICATION_SUSPENDED_CONSTRAINT, "Unable to test availability constraints as the application " + applicationApi.applicationId() + " is allowed to be down");
}
// Apply per-cluster policy
for (ClusterApi cluster : applicationApi.getClusters()) {
clusterPolicy.verifyGroupGoingDownPermanentlyIsFine(cluster);
}
// These storage nodes are guaranteed to be NO_REMARKS
for (StorageNode storageNode : applicationApi.getStorageNodesInGroupInClusterOrder()) {
storageNode.setNodeState(ClusterControllerNodeState.DOWN);
log.log(LogLevel.INFO, "The storage node on " + storageNode.hostName() + " has been set DOWN");
}
// Ensure all nodes in the group are marked as allowed to be down
for (HostName hostName : applicationApi.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)) {
applicationApi.setHostState(hostName, HostStatus.ALLOWED_TO_BE_DOWN);
log.log(LogLevel.INFO, hostName + " is now allowed to be down (suspended)");
}
}
use of com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus in project vespa by vespa-engine.
the class OrchestratorImpl method resume.
@Override
public void resume(HostName hostName) throws HostStateChangeDeniedException, HostNameNotFoundException {
/*
* When making a state transition to this state, we have to consider that if the host has been in
* ALLOWED_TO_BE_DOWN state, services on the host may recently have been stopped (and, presumably, started).
* Service monitoring may not have had enough time to detect that services were stopped,
* and may therefore mistakenly report services as up, even if they still haven't initialized and
* are not yet ready for serving. Erroneously reporting both host and services as up causes a race
* where services on other hosts may be stopped prematurely. A delay here ensures that service
* monitoring will have had time to catch up. Since we don't want do the delay with the lock held,
* and the host status service's locking functionality does not support something like condition
* variables or Object.wait(), we break out here, releasing the lock before delaying.
*/
sleep(serviceMonitorConvergenceLatencySeconds, TimeUnit.SECONDS);
ApplicationInstance appInstance = getApplicationInstance(hostName);
try (MutableStatusRegistry statusRegistry = statusService.lockApplicationInstance_forCurrentThreadOnly(appInstance.reference())) {
final HostStatus currentHostState = statusRegistry.getHostStatus(hostName);
if (HostStatus.NO_REMARKS == currentHostState) {
return;
}
ApplicationInstanceStatus appStatus = statusService.forApplicationInstance(appInstance.reference()).getApplicationInstanceStatus();
if (appStatus == ApplicationInstanceStatus.NO_REMARKS) {
policy.releaseSuspensionGrant(appInstance, hostName, statusRegistry);
}
}
}
use of com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus in project vespa by vespa-engine.
the class ApplicationSuspensionResource method getApplication.
@Override
public void getApplication(String applicationIdString) {
ApplicationId appId = toApplicationId(applicationIdString);
ApplicationInstanceStatus status;
try {
status = orchestrator.getApplicationInstanceStatus(appId);
} catch (ApplicationIdNotFoundException e) {
throw new NotFoundException("Application " + applicationIdString + " could not be found");
}
if (status.equals(ApplicationInstanceStatus.NO_REMARKS)) {
throw new NotFoundException("Application " + applicationIdString + " is not suspended");
}
// Return void as we have nothing to return except 204 No
// Content. Unfortunately, Jersey outputs a warning for this case:
//
// The following warnings have been detected: HINT: A HTTP GET
// method, public void com.yahoo.vespa.orchestrator.resources.
// ApplicationSuspensionResource.getApplication(java.lang.String),
// returns a void type. It can be intentional and perfectly fine,
// but it is a little uncommon that GET method returns always "204
// No Content"
//
// We have whitelisted the warning for our systemtests.
//
// bakksjo has a pending jersey PR fix that avoids making the hint
// become a warning:
// https://github.com/jersey/jersey/pull/212
//
// TODO: Remove whitelisting and this comment once jersey has been
// fixed.
}
use of com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus in project vespa by vespa-engine.
the class OrchestratorImpl method suspendGroup.
// Public for testing purposes
@Override
public void suspendGroup(NodeGroup nodeGroup) throws HostStateChangeDeniedException, HostNameNotFoundException {
ApplicationInstanceReference applicationReference = nodeGroup.getApplicationReference();
try (MutableStatusRegistry hostStatusRegistry = statusService.lockApplicationInstance_forCurrentThreadOnly(applicationReference)) {
ApplicationInstanceStatus appStatus = statusService.forApplicationInstance(applicationReference).getApplicationInstanceStatus();
if (appStatus == ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN) {
return;
}
ApplicationApi applicationApi = new ApplicationApiImpl(nodeGroup, hostStatusRegistry, clusterControllerClientFactory);
policy.grantSuspensionRequest(applicationApi);
}
}
Aggregations