Search in sources :

Example 16 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment in project vespa by vespa-engine.

the class DeploymentTrigger method changeDeployed.

/**
 * Returns whether the given application should skip deployment of its current change to the given production job zone.
 *
 * If the currently deployed application has a newer platform or application version than the application's
 * current change, the method returns {@code true}, to avoid a downgrade.
 * Otherwise, it returns whether the current change is redundant, i.e., all its components are already deployed.
 */
private boolean changeDeployed(Application application, JobType job) {
    if (!job.isProduction())
        throw new IllegalArgumentException(job + " is not a production job!");
    Deployment deployment = application.deployments().get(job.zone(controller.system()).get());
    if (deployment == null)
        return false;
    int applicationComparison = application.change().application().map(version -> version.compareTo(deployment.applicationVersion())).orElse(0);
    int platformComparion = application.change().platform().map(version -> version.compareTo(deployment.version())).orElse(0);
    if (applicationComparison == -1 || platformComparion == -1)
        // Avoid downgrades!
        return true;
    return applicationComparison == 0 && platformComparion == 0;
}
Also used : Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) JobReport(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) JobList(com.yahoo.vespa.hosted.controller.application.JobList) Change(com.yahoo.vespa.hosted.controller.application.Change) Duration(java.time.Duration) JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationController(com.yahoo.vespa.hosted.controller.ApplicationController) Collection(java.util.Collection) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) CuratorDb(com.yahoo.vespa.hosted.controller.persistence.CuratorDb) Instant(java.time.Instant) Logger(java.util.logging.Logger) JobError(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError) Objects(java.util.Objects) JobType(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType) List(java.util.List) Stream(java.util.stream.Stream) SystemName(com.yahoo.config.provision.SystemName) Clock(java.time.Clock) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) Collections(java.util.Collections) Controller(com.yahoo.vespa.hosted.controller.Controller) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment)

Example 17 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment in project vespa by vespa-engine.

the class ClusterInfoMaintainer method maintain.

@Override
protected void maintain() {
    for (Application application : ApplicationList.from(controller().applications().asList()).notPullRequest().asList()) {
        for (Deployment deployment : application.deployments().values()) {
            DeploymentId deploymentId = new DeploymentId(application.id(), deployment.zone());
            try {
                NodeList nodes = controller.nodeRepositoryClient().listNodes(deploymentId.zoneId(), deploymentId.applicationId().tenant().value(), deploymentId.applicationId().application().value(), deploymentId.applicationId().instance().value());
                Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes, deployment.zone());
                controller().applications().lockIfPresent(application.id(), lockedApplication -> controller.applications().store(lockedApplication.withClusterInfo(deployment.zone(), clusterInfo)));
            } catch (IOException | IllegalArgumentException e) {
                log.log(Level.WARNING, "Failing getting cluster info of for " + deploymentId, e);
            }
        }
    }
}
Also used : DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) IOException(java.io.IOException) Application(com.yahoo.vespa.hosted.controller.Application)

Example 18 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment in project vespa by vespa-engine.

the class DeploymentMetricsMaintainer method maintain.

@Override
protected void maintain() {
    boolean hasWarned = false;
    for (Application application : ApplicationList.from(controller().applications().asList()).notPullRequest().asList()) {
        try {
            controller().applications().lockIfPresent(application.id(), lockedApplication -> controller().applications().store(lockedApplication.with(controller().metricsService().getApplicationMetrics(application.id()))));
            for (Deployment deployment : application.deployments().values()) {
                MetricsService.DeploymentMetrics deploymentMetrics = controller().metricsService().getDeploymentMetrics(application.id(), deployment.zone());
                DeploymentMetrics appMetrics = new DeploymentMetrics(deploymentMetrics.queriesPerSecond(), deploymentMetrics.writesPerSecond(), deploymentMetrics.documentCount(), deploymentMetrics.queryLatencyMillis(), deploymentMetrics.writeLatencyMillis());
                controller().applications().lockIfPresent(application.id(), lockedApplication -> controller().applications().store(lockedApplication.with(deployment.zone(), appMetrics)));
            }
        } catch (UncheckedIOException e) {
            if (// produce only one warning per maintenance interval
            !hasWarned)
                log.log(Level.WARNING, "Failed talking to YAMAS: " + Exceptions.toMessageString(e) + ". Retrying in " + maintenanceInterval());
            hasWarned = true;
        }
    }
}
Also used : DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) MetricsService(com.yahoo.vespa.hosted.controller.api.integration.MetricsService) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) UncheckedIOException(java.io.UncheckedIOException) Application(com.yahoo.vespa.hosted.controller.Application)

Example 19 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment in project vespa by vespa-engine.

the class ApplicationSerializerTest method testSerialization.

@Test
public void testSerialization() {
    ControllerTester tester = new ControllerTester();
    DeploymentSpec deploymentSpec = DeploymentSpec.fromXml("<deployment version='1.0'>" + "   <staging/>" + "</deployment>");
    ValidationOverrides validationOverrides = ValidationOverrides.fromXml("<validation-overrides version='1.0'>" + "  <allow until='2017-06-15'>deployment-removal</allow>" + "</validation-overrides>");
    List<Deployment> deployments = new ArrayList<>();
    ApplicationVersion applicationVersion1 = ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 31);
    ApplicationVersion applicationVersion2 = ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 32);
    // One deployment without cluster info and utils
    deployments.add(new Deployment(zone1, applicationVersion1, Version.fromString("1.2.3"), Instant.ofEpochMilli(3)));
    deployments.add(new Deployment(zone2, applicationVersion2, Version.fromString("1.2.3"), Instant.ofEpochMilli(5), createClusterUtils(3, 0.2), createClusterInfo(3, 4), new DeploymentMetrics(2, 3, 4, 5, 6)));
    Optional<Long> projectId = Optional.of(123L);
    List<JobStatus> statusList = new ArrayList<>();
    statusList.add(JobStatus.initial(DeploymentJobs.JobType.systemTest).withTriggering(Version.fromString("5.6.7"), ApplicationVersion.unknown, "Test", Instant.ofEpochMilli(7)).withCompletion(30, Optional.empty(), Instant.ofEpochMilli(8), tester.controller()));
    statusList.add(JobStatus.initial(DeploymentJobs.JobType.stagingTest).withTriggering(Version.fromString("5.6.6"), ApplicationVersion.unknown, "Test 2", Instant.ofEpochMilli(5)).withCompletion(11, Optional.of(JobError.unknown), Instant.ofEpochMilli(6), tester.controller()));
    DeploymentJobs deploymentJobs = new DeploymentJobs(projectId, statusList, Optional.empty());
    Application original = new Application(ApplicationId.from("t1", "a1", "i1"), deploymentSpec, validationOverrides, deployments, deploymentJobs, Change.of(Version.fromString("6.7")), Change.of(ApplicationVersion.from(new SourceRevision("repo", "master", "deadcafe"), 42)), Optional.of(IssueId.from("1234")), new MetricsService.ApplicationMetrics(0.5, 0.9), Optional.of(new RotationId("my-rotation")));
    Application serialized = applicationSerializer.fromSlime(applicationSerializer.toSlime(original));
    assertEquals(original.id(), serialized.id());
    assertEquals(original.deploymentSpec().xmlForm(), serialized.deploymentSpec().xmlForm());
    assertEquals(original.validationOverrides().xmlForm(), serialized.validationOverrides().xmlForm());
    assertEquals(2, serialized.deployments().size());
    assertEquals(original.deployments().get(zone1).applicationVersion(), serialized.deployments().get(zone1).applicationVersion());
    assertEquals(original.deployments().get(zone2).applicationVersion(), serialized.deployments().get(zone2).applicationVersion());
    assertEquals(original.deployments().get(zone1).version(), serialized.deployments().get(zone1).version());
    assertEquals(original.deployments().get(zone2).version(), serialized.deployments().get(zone2).version());
    assertEquals(original.deployments().get(zone1).at(), serialized.deployments().get(zone1).at());
    assertEquals(original.deployments().get(zone2).at(), serialized.deployments().get(zone2).at());
    assertEquals(original.deploymentJobs().projectId(), serialized.deploymentJobs().projectId());
    assertEquals(original.deploymentJobs().jobStatus().size(), serialized.deploymentJobs().jobStatus().size());
    assertEquals(original.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.systemTest), serialized.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.systemTest));
    assertEquals(original.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.stagingTest), serialized.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.stagingTest));
    assertEquals(original.outstandingChange(), serialized.outstandingChange());
    assertEquals(original.ownershipIssueId(), serialized.ownershipIssueId());
    assertEquals(original.change(), serialized.change());
    assertEquals(original.rotation().get().id(), serialized.rotation().get().id());
    // Test cluster utilization
    assertEquals(0, serialized.deployments().get(zone1).clusterUtils().size());
    assertEquals(3, serialized.deployments().get(zone2).clusterUtils().size());
    assertEquals(0.4, serialized.deployments().get(zone2).clusterUtils().get(ClusterSpec.Id.from("id2")).getCpu(), 0.01);
    assertEquals(0.2, serialized.deployments().get(zone2).clusterUtils().get(ClusterSpec.Id.from("id1")).getCpu(), 0.01);
    assertEquals(0.2, serialized.deployments().get(zone2).clusterUtils().get(ClusterSpec.Id.from("id1")).getMemory(), 0.01);
    // Test cluster info
    assertEquals(3, serialized.deployments().get(zone2).clusterInfo().size());
    assertEquals(10, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorCost());
    assertEquals(ClusterSpec.Type.content, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getClusterType());
    assertEquals("flavor2", serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavor());
    assertEquals(4, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getHostnames().size());
    assertEquals(2, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorCPU(), Double.MIN_VALUE);
    assertEquals(4, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorMem(), Double.MIN_VALUE);
    assertEquals(50, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorDisk(), Double.MIN_VALUE);
    // Test metrics
    assertEquals(original.metrics().queryServiceQuality(), serialized.metrics().queryServiceQuality(), Double.MIN_VALUE);
    assertEquals(original.metrics().writeServiceQuality(), serialized.metrics().writeServiceQuality(), Double.MIN_VALUE);
    assertEquals(2, serialized.deployments().get(zone2).metrics().queriesPerSecond(), Double.MIN_VALUE);
    assertEquals(3, serialized.deployments().get(zone2).metrics().writesPerSecond(), Double.MIN_VALUE);
    assertEquals(4, serialized.deployments().get(zone2).metrics().documentCount(), Double.MIN_VALUE);
    assertEquals(5, serialized.deployments().get(zone2).metrics().queryLatencyMillis(), Double.MIN_VALUE);
    assertEquals(6, serialized.deployments().get(zone2).metrics().writeLatencyMillis(), Double.MIN_VALUE);
    {
        // test more deployment serialization cases
        Application original2 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 42)));
        Application serialized2 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original2));
        assertEquals(original2.change(), serialized2.change());
        assertEquals(serialized2.change().application().get().source(), original2.change().application().get().source());
        Application original3 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42)));
        Application serialized3 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original3));
        assertEquals(original3.change(), serialized3.change());
        assertEquals(serialized3.change().application().get().source(), original3.change().application().get().source());
        Application original4 = writable(original).withChange(Change.empty());
        Application serialized4 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original4));
        assertEquals(original4.change(), serialized4.change());
        Application original5 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42)));
        Application serialized5 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original5));
        assertEquals(original5.change(), serialized5.change());
        Application original6 = writable(original).withOutstandingChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42)));
        Application serialized6 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original6));
        assertEquals(original6.outstandingChange(), serialized6.outstandingChange());
    }
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) MetricsService(com.yahoo.vespa.hosted.controller.api.integration.MetricsService) ArrayList(java.util.ArrayList) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ValidationOverrides(com.yahoo.config.application.api.ValidationOverrides) RotationId(com.yahoo.vespa.hosted.controller.rotation.RotationId) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test)

Example 20 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment in project vespa by vespa-engine.

the class ApplicationApiTest method setDeploymentMaintainedInfo.

/**
 * Cluster info, utilization and application and deployment metrics are maintained async by maintainers.
 *
 * This sets these values as if the maintainers has been ran.
 *
 * @param controllerTester
 */
private void setDeploymentMaintainedInfo(ContainerControllerTester controllerTester) {
    for (Application application : controllerTester.controller().applications().asList()) {
        controllerTester.controller().applications().lockOrThrow(application.id(), lockedApplication -> {
            lockedApplication = lockedApplication.with(new ApplicationMetrics(0.5, 0.7));
            for (Deployment deployment : application.deployments().values()) {
                Map<ClusterSpec.Id, ClusterInfo> clusterInfo = new HashMap<>();
                List<String> hostnames = new ArrayList<>();
                hostnames.add("host1");
                hostnames.add("host2");
                clusterInfo.put(ClusterSpec.Id.from("cluster1"), new ClusterInfo("flavor1", 37, 2, 4, 50, ClusterSpec.Type.content, hostnames));
                Map<ClusterSpec.Id, ClusterUtilization> clusterUtils = new HashMap<>();
                clusterUtils.put(ClusterSpec.Id.from("cluster1"), new ClusterUtilization(0.3, 0.6, 0.4, 0.3));
                DeploymentMetrics metrics = new DeploymentMetrics(1, 2, 3, 4, 5);
                lockedApplication = lockedApplication.withClusterInfo(deployment.zone(), clusterInfo).withClusterUtilization(deployment.zone(), clusterUtils).with(deployment.zone(), metrics);
            }
            controllerTester.controller().applications().store(lockedApplication);
        });
    }
}
Also used : DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) IssueId(com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId) ApplicationId(com.yahoo.config.provision.ApplicationId) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId) UserId(com.yahoo.vespa.hosted.controller.api.identifiers.UserId) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) ApplicationMetrics(com.yahoo.vespa.hosted.controller.api.integration.MetricsService.ApplicationMetrics) Application(com.yahoo.vespa.hosted.controller.Application)

Aggregations

Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)21 Application (com.yahoo.vespa.hosted.controller.Application)15 ApplicationId (com.yahoo.config.provision.ApplicationId)12 Version (com.yahoo.component.Version)9 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)9 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)7 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)6 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)6 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)6 DeploymentJobs (com.yahoo.vespa.hosted.controller.application.DeploymentJobs)6 Collections (java.util.Collections)6 List (java.util.List)6 Optional (java.util.Optional)6 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)5 DeploymentMetrics (com.yahoo.vespa.hosted.controller.application.DeploymentMetrics)5 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 Environment (com.yahoo.config.provision.Environment)4 TenantName (com.yahoo.config.provision.TenantName)4 JobStatus (com.yahoo.vespa.hosted.controller.application.JobStatus)4