diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-10-08 10:38:32 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-10-08 10:38:32 +0200 |
commit | 2770622bfce25deeb1e9334604fbab874bf0eca5 (patch) | |
tree | 4818c5cef6cc4dcfffde5df626f13b219749f957 /controller-server | |
parent | 8f911ea0fe8f64286597923333254f03f751d2c6 (diff) |
Use more latestVersion and update some tests
Diffstat (limited to 'controller-server')
7 files changed, 22 insertions, 52 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java index 2fa0d6d4b91..a1758797065 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java @@ -143,7 +143,9 @@ public class DeploymentTrigger { applications().lockApplicationOrThrow(TenantAndApplicationId.from(report.applicationId()), application -> { if (report.jobType() == component) { - notifyOfSubmission(application.get().id(), report.version().get(), report.projectId()); + if (report.success()) + notifyOfSubmission(application.get().id(), report.version().get(), report.projectId()); + return; } JobRun triggering; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java index 9253e249765..4356fd8ef42 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java @@ -3,8 +3,10 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ApplicationId; import com.yahoo.jdisc.Metric; +import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.Instance; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationList; import com.yahoo.vespa.hosted.controller.application.Deployment; @@ -66,10 +68,12 @@ public class MetricsReporter extends Maintainer { } private void reportDeploymentMetrics() { - List<Instance> instances = ApplicationList.from(controller().applications().asList()) - .withProductionDeployment().asList().stream() - .flatMap(application -> application.instances().values().stream()) - .collect(Collectors.toUnmodifiableList()); + List<Application> applications = ApplicationList.from(controller().applications().asList()) + .withProductionDeployment().asList().stream() + .collect(Collectors.toUnmodifiableList()); + List<Instance> instances = applications.stream() + .flatMap(application -> application.instances().values().stream()) + .collect(Collectors.toUnmodifiableList()); metric.set(DEPLOYMENT_FAIL_METRIC, deploymentFailRatio(instances) * 100, metric.createContext(Map.of())); @@ -85,13 +89,12 @@ public class MetricsReporter extends Maintainer { metric.set(DEPLOYMENT_WARNINGS, warnings, metric.createContext(dimensions(application))); }); - for (Instance instance : instances) - instance.deploymentJobs().statusOf(JobType.component) - .flatMap(JobStatus::lastSuccess) - .flatMap(run -> run.application().buildTime()) + for (Application application : applications) + application.latestVersion() + .flatMap(ApplicationVersion::buildTime) .ifPresent(buildTime -> metric.set(DEPLOYMENT_BUILD_AGE_SECONDS, controller().clock().instant().getEpochSecond() - buildTime.getEpochSecond(), - metric.createContext(dimensions(instance.id())))); + metric.createContext(dimensions(application.id().defaultInstance())))); } private void reportQueuedNameServiceRequests() { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index c37309b87ad..16eaa44aa74 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -572,10 +572,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { "/instance/" + instance.id().instance().value() + "/job/", request.getUri()).toString()); - instance.deploymentJobs().statusOf(JobType.component) - .flatMap(JobStatus::lastSuccess) - .map(run -> run.application().source()) - .ifPresent(source -> sourceRevisionToSlime(source, object.setObject("source"))); + application.latestVersion().ifPresent(version -> sourceRevisionToSlime(version.source(), object.setObject("source"))); application.projectId().ifPresent(id -> object.setLong("projectId", id)); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index ebf80eb9daa..fc7f22f5ef4 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -89,7 +89,7 @@ public class ControllerTest { tester.application(app1.id()).change().application().get()); tester.deployAndNotify(instance.id(), Optional.of(applicationPackage), true, systemTest); tester.deployAndNotify(instance.id(), Optional.of(applicationPackage), true, stagingTest); - assertEquals(4, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); + assertEquals(3, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); ApplicationVersion applicationVersion = tester.application(app1.id()).change().application().get(); assertFalse("Application version has been set during deployment", applicationVersion.isUnknown()); @@ -105,7 +105,7 @@ public class ControllerTest { // production job (failing) after deployment tester.deploy(productionUsWest1, instance.id(), applicationPackage); tester.deployAndNotify(instance.id(), Optional.of(applicationPackage), false, productionUsWest1); - assertEquals(4, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); + assertEquals(3, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); JobStatus expectedJobStatus = JobStatus.initial(productionUsWest1) .withTriggering(version1, applicationVersion, Optional.empty(), "", tester.clock().instant().truncatedTo(MILLIS)) // Triggered first without application version info @@ -123,7 +123,7 @@ public class ControllerTest { assertNotNull(tester.controller().tenants().get(TenantName.from("tenant1"))); assertNotNull(tester.defaultInstance(app1.id())); - assertEquals(4, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); + assertEquals(3, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); tester.clock().advance(Duration.ofHours(1)); @@ -153,7 +153,7 @@ public class ControllerTest { app1.id().defaultInstance(), tester.controller()); tester.deployAndNotify(instance.id(), Optional.of(applicationPackage), true, productionUsEast3); - assertEquals(5, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); + assertEquals(4, tester.defaultInstance(app1.id()).deploymentJobs().jobStatus().size()); // Production zone for which there is no JobType is not allowed. applicationPackage = new ApplicationPackageBuilder() diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java index d979f1753c4..1fd51a453fd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java @@ -592,7 +592,7 @@ public class UpgraderTest { tester.jobCompletion(component).application(default2).nextBuildNumber().uploadArtifact(canaryPolicy).unsuccessful().submit(); tester.jobCompletion(component).application(default3).nextBuildNumber(2).uploadArtifact(canaryPolicy).unsuccessful().submit(); tester.upgradeSystem(version); - assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence()); + assertEquals(VespaVersion.Confidence.high, tester.controller().versionStatus().systemVersion().get().confidence()); } @Test diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 7061af3904f..83972fbcd79 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -1479,7 +1479,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // ... and assert it was recorded JobStatus recordedStatus = - tester.controller().applications().getInstance(app.id().defaultInstance()).get().deploymentJobs().jobStatus().get(JobType.component); + tester.controller().applications().getInstance(app.id().defaultInstance()).get().deploymentJobs().jobStatus().get(JobType.systemTest); assertNotNull("Status was recorded", recordedStatus); assertTrue(recordedStatus.isSuccess()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-without-change-multiple-deployments.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-without-change-multiple-deployments.json index 3579f64f6c9..6f571c223bd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-without-change-multiple-deployments.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-without-change-multiple-deployments.json @@ -12,38 +12,6 @@ "deployedInternally": false, "deploymentJobs": [ { - "type": "component", - "success": true, - "lastCompleted": { - "id": 101, - "version": "(ignore)", - "revision": { - "hash": "(ignore)", - "source": { - "gitRepository": "repository1", - "gitBranch": "master", - "gitCommit": "commit1" - } - }, - "reason": "Application commit", - "at": "(ignore)" - }, - "lastSuccess": { - "id": 101, - "version": "(ignore)", - "revision": { - "hash": "(ignore)", - "source": { - "gitRepository": "repository1", - "gitBranch": "master", - "gitCommit": "commit1" - } - }, - "reason": "Application commit", - "at": "(ignore)" - } - }, - { "type": "system-test", "success": true, "lastTriggered": { |