Search in sources :

Example 1 with Log

use of com.yahoo.vespa.hosted.controller.api.integration.configserver.Log in project vespa by vespa-engine.

the class ApplicationController method unexpectedDeployment.

private ActivateResult unexpectedDeployment(ApplicationId applicationId, ZoneId zone, Optional<ApplicationPackage> applicationPackage) {
    Log logEntry = new Log();
    logEntry.level = "WARNING";
    logEntry.time = clock.instant().toEpochMilli();
    logEntry.message = "Ignoring deployment of " + require(applicationId) + " to " + zone + " as a deployment is not currently expected";
    PrepareResponse prepareResponse = new PrepareResponse();
    prepareResponse.log = Collections.singletonList(logEntry);
    prepareResponse.configChangeActions = new ConfigChangeActions(Collections.emptyList(), Collections.emptyList());
    return new ActivateResult(new RevisionId(applicationPackage.map(ApplicationPackage::hash).orElse("0")), prepareResponse, applicationPackage.map(a -> a.zippedContent().length).orElse(0));
}
Also used : ActivateResult(com.yahoo.vespa.hosted.controller.api.ActivateResult) PrepareResponse(com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse) Log(com.yahoo.vespa.hosted.controller.api.integration.configserver.Log) ConfigChangeActions(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions) RevisionId(com.yahoo.vespa.hosted.controller.api.identifiers.RevisionId)

Example 2 with Log

use of com.yahoo.vespa.hosted.controller.api.integration.configserver.Log in project vespa by vespa-engine.

the class ConfigServerClientMock method prepare.

@Override
public PreparedApplication prepare(DeploymentId deployment, DeployOptions deployOptions, Set<String> rotationCnames, Set<String> rotationNames, byte[] content) {
    lastPrepareVersion = deployOptions.vespaVersion.map(Version::new).orElse(null);
    if (prepareException != null) {
        RuntimeException prepareException = this.prepareException;
        this.prepareException = null;
        throw prepareException;
    }
    applicationActivated.put(deployment.applicationId(), false);
    applicationInstances.put(deployment.applicationId(), UUID.randomUUID() + ":4080");
    return new PreparedApplication() {

        @Override
        public void activate() {
            applicationActivated.put(deployment.applicationId(), true);
        }

        @Override
        public List<Log> messages() {
            Log warning = new Log();
            warning.level = "WARNING";
            warning.time = 1;
            warning.message = "The warning";
            Log info = new Log();
            info.level = "INFO";
            info.time = 2;
            info.message = "The info";
            return Arrays.asList(warning, info);
        }

        @Override
        public PrepareResponse prepareResponse() {
            PrepareResponse prepareResponse = new PrepareResponse();
            prepareResponse.message = "foo";
            prepareResponse.configChangeActions = new ConfigChangeActions(Collections.emptyList(), Collections.emptyList());
            prepareResponse.tenant = new TenantId("tenant");
            return prepareResponse;
        }
    };
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) PrepareResponse(com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse) Version(com.yahoo.component.Version) Log(com.yahoo.vespa.hosted.controller.api.integration.configserver.Log) ConfigChangeActions(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions)

Example 3 with Log

use of com.yahoo.vespa.hosted.controller.api.integration.configserver.Log in project vespa by vespa-engine.

the class ApplicationApiHandler method toSlime.

private Slime toSlime(ActivateResult result) {
    Slime slime = new Slime();
    Cursor object = slime.setObject();
    object.setString("revisionId", result.revisionId().id());
    object.setLong("applicationZipSize", result.applicationZipSizeBytes());
    Cursor logArray = object.setArray("prepareMessages");
    if (result.prepareResponse().log != null) {
        for (Log logMessage : result.prepareResponse().log) {
            Cursor logObject = logArray.addObject();
            logObject.setLong("time", logMessage.time);
            logObject.setString("level", logMessage.level);
            logObject.setString("message", logMessage.message);
        }
    }
    Cursor changeObject = object.setObject("configChangeActions");
    Cursor restartActionsArray = changeObject.setArray("restart");
    for (RestartAction restartAction : result.prepareResponse().configChangeActions.restartActions) {
        Cursor restartActionObject = restartActionsArray.addObject();
        restartActionObject.setString("clusterName", restartAction.clusterName);
        restartActionObject.setString("clusterType", restartAction.clusterType);
        restartActionObject.setString("serviceType", restartAction.serviceType);
        serviceInfosToSlime(restartAction.services, restartActionObject.setArray("services"));
        stringsToSlime(restartAction.messages, restartActionObject.setArray("messages"));
    }
    Cursor refeedActionsArray = changeObject.setArray("refeed");
    for (RefeedAction refeedAction : result.prepareResponse().configChangeActions.refeedActions) {
        Cursor refeedActionObject = refeedActionsArray.addObject();
        refeedActionObject.setString("name", refeedAction.name);
        refeedActionObject.setBool("allowed", refeedAction.allowed);
        refeedActionObject.setString("documentType", refeedAction.documentType);
        refeedActionObject.setString("clusterName", refeedAction.clusterName);
        serviceInfosToSlime(refeedAction.services, refeedActionObject.setArray("services"));
        stringsToSlime(refeedAction.messages, refeedActionObject.setArray("messages"));
    }
    return slime;
}
Also used : Log(com.yahoo.vespa.hosted.controller.api.integration.configserver.Log) RestartAction(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RestartAction) RefeedAction(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RefeedAction) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Aggregations

Log (com.yahoo.vespa.hosted.controller.api.integration.configserver.Log)3 ConfigChangeActions (com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions)2 PrepareResponse (com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse)2 Version (com.yahoo.component.Version)1 Cursor (com.yahoo.slime.Cursor)1 Slime (com.yahoo.slime.Slime)1 ActivateResult (com.yahoo.vespa.hosted.controller.api.ActivateResult)1 RefeedAction (com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RefeedAction)1 RestartAction (com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RestartAction)1 RevisionId (com.yahoo.vespa.hosted.controller.api.identifiers.RevisionId)1 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)1