Search in sources :

Example 1 with ApplicationInstanceStatus

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)");
    }
}
Also used : ClusterApi(com.yahoo.vespa.orchestrator.model.ClusterApi) ApplicationInstanceStatus(com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus) StorageNode(com.yahoo.vespa.orchestrator.model.StorageNode) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 2 with ApplicationInstanceStatus

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);
        }
    }
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) MutableStatusRegistry(com.yahoo.vespa.orchestrator.status.MutableStatusRegistry) ApplicationInstanceStatus(com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus)

Example 3 with ApplicationInstanceStatus

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.
}
Also used : ApplicationIdNotFoundException(com.yahoo.vespa.orchestrator.ApplicationIdNotFoundException) ApplicationInstanceStatus(com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus) NotFoundException(javax.ws.rs.NotFoundException) ApplicationIdNotFoundException(com.yahoo.vespa.orchestrator.ApplicationIdNotFoundException) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 4 with ApplicationInstanceStatus

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);
    }
}
Also used : ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) ApplicationApiImpl(com.yahoo.vespa.orchestrator.model.ApplicationApiImpl) MutableStatusRegistry(com.yahoo.vespa.orchestrator.status.MutableStatusRegistry) ApplicationInstanceStatus(com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)

Aggregations

ApplicationInstanceStatus (com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus)4 MutableStatusRegistry (com.yahoo.vespa.orchestrator.status.MutableStatusRegistry)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)1 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)1 HostName (com.yahoo.vespa.applicationmodel.HostName)1 ApplicationIdNotFoundException (com.yahoo.vespa.orchestrator.ApplicationIdNotFoundException)1 ApplicationApi (com.yahoo.vespa.orchestrator.model.ApplicationApi)1 ApplicationApiImpl (com.yahoo.vespa.orchestrator.model.ApplicationApiImpl)1 ClusterApi (com.yahoo.vespa.orchestrator.model.ClusterApi)1 StorageNode (com.yahoo.vespa.orchestrator.model.StorageNode)1 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)1 NotFoundException (javax.ws.rs.NotFoundException)1