Search in sources :

Example 1 with HttpException

use of com.yahoo.vespa.hosted.node.admin.configserver.HttpException in project vespa by vespa-engine.

the class NodeAdminStateUpdaterImpl method tick.

void tick() {
    State wantedStateCopy;
    synchronized (monitor) {
        while (!workToDoNow) {
            Duration timeSinceLastConverge = Duration.between(lastTick, clock.instant());
            long remainder = nodeAdminConvergeStateInterval.minus(timeSinceLastConverge).toMillis();
            if (remainder > 0) {
                try {
                    monitor.wait(remainder);
                } catch (InterruptedException e) {
                    log.info("Interrupted, but ignoring this: NodeAdminStateUpdater");
                }
            } else
                break;
        }
        lastTick = clock.instant();
        workToDoNow = false;
        // wantedState may change asynchronously, so we grab a copy of it here
        wantedStateCopy = this.wantedState;
    }
    try {
        convergeState(wantedStateCopy);
    } catch (OrchestratorException | ConvergenceException | HttpException e) {
        log.info("Unable to converge to " + wantedStateCopy + ": " + e.getMessage());
    } catch (Exception e) {
        log.log(LogLevel.ERROR, "Error while trying to converge to " + wantedStateCopy, e);
    }
    if (wantedStateCopy != RESUMED && currentState == TRANSITIONING) {
        Duration subsystemFreezeDuration = nodeAdmin.subsystemFreezeDuration();
        if (subsystemFreezeDuration.compareTo(FREEZE_CONVERGENCE_TIMEOUT) > 0) {
            // We have spent too much time trying to freeze and node admin is still not frozen.
            // To avoid node agents stalling for too long, we'll force unfrozen ticks now.
            log.info("Timed out trying to freeze, will force unfreezed ticks");
            nodeAdmin.setFrozen(false);
        }
    }
    fetchContainersToRunFromNodeRepository();
}
Also used : OrchestratorException(com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException) Duration(java.time.Duration) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) LockInterruptException(com.yahoo.concurrent.classlock.LockInterruptException) OrchestratorException(com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException)

Example 2 with HttpException

use of com.yahoo.vespa.hosted.node.admin.configserver.HttpException in project vespa by vespa-engine.

the class OrchestratorImpl method resume.

@Override
public void resume(final String hostName) {
    UpdateHostResponse response;
    try {
        String path = getSuspendPath(hostName);
        response = configServerApi.delete(path, UpdateHostResponse.class);
    } catch (HttpException.NotFoundException n) {
        throw new OrchestratorNotFoundException("Failed to resume " + hostName + ", host not found");
    } catch (HttpException e) {
        throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString());
    } catch (Exception e) {
        throw new RuntimeException("Got error on resume", e);
    }
    Optional.ofNullable(response.reason()).ifPresent(reason -> {
        throw new OrchestratorException(reason.message());
    });
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException)

Example 3 with HttpException

use of com.yahoo.vespa.hosted.node.admin.configserver.HttpException in project vespa by vespa-engine.

the class OrchestratorImpl method suspend.

@Override
public void suspend(String parentHostName, List<String> hostNames) {
    final BatchOperationResult batchOperationResult;
    try {
        String params = String.join("&hostname=", hostNames);
        String url = String.format("%s/%s?hostname=%s", ORCHESTRATOR_PATH_PREFIX_HOST_SUSPENSION_API, parentHostName, params);
        batchOperationResult = configServerApi.put(url, Optional.empty(), BatchOperationResult.class);
    } catch (HttpException e) {
        throw new OrchestratorException("Failed to batch suspend for " + parentHostName + ": " + e.toString());
    } catch (Exception e) {
        throw new RuntimeException("Got error on batch suspend for " + parentHostName + ", with nodes " + hostNames, e);
    }
    batchOperationResult.getFailureReason().ifPresent(reason -> {
        throw new OrchestratorException(reason);
    });
}
Also used : HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) BatchOperationResult(com.yahoo.vespa.orchestrator.restapi.wire.BatchOperationResult) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException)

Example 4 with HttpException

use of com.yahoo.vespa.hosted.node.admin.configserver.HttpException in project vespa by vespa-engine.

the class OrchestratorImpl method suspend.

@Override
public void suspend(final String hostName) {
    UpdateHostResponse response;
    try {
        response = configServerApi.put(getSuspendPath(hostName), Optional.empty(), /* body */
        UpdateHostResponse.class);
    } catch (HttpException.NotFoundException n) {
        throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found");
    } catch (HttpException e) {
        throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString());
    } catch (Exception e) {
        throw new RuntimeException("Got error on suspend", e);
    }
    Optional.ofNullable(response.reason()).ifPresent(reason -> {
        throw new OrchestratorException(reason.message());
    });
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException)

Aggregations

HttpException (com.yahoo.vespa.hosted.node.admin.configserver.HttpException)4 UpdateHostResponse (com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse)2 LockInterruptException (com.yahoo.concurrent.classlock.LockInterruptException)1 OrchestratorException (com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException)1 BatchOperationResult (com.yahoo.vespa.orchestrator.restapi.wire.BatchOperationResult)1 Duration (java.time.Duration)1