diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2023-06-15 14:16:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-15 14:16:41 +0200 |
commit | ba98a6d14f2d9f6b543ac102ef793942b07e3941 (patch) | |
tree | 1aa565c7e1cc7a89733c38e7b7ca3981e8cb4bbc /controller-server/src | |
parent | 4a5f76d4840af80588159edfe574b25847ba1307 (diff) | |
parent | 3f6706b3410631620bce20d9695790dc33a9ddc0 (diff) |
Merge pull request #27434 from vespa-engine/jonmv/cloud-account-in-deployment-v1-api
Add cloud account details in /deployment/v1 as well
Diffstat (limited to 'controller-server/src')
5 files changed, 43 insertions, 20 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java index 544863b708e..b0a6ad214d8 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java @@ -15,6 +15,7 @@ import com.yahoo.text.Text; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.NotExistsException; +import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobId; @@ -22,6 +23,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RevisionId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId; import com.yahoo.vespa.hosted.controller.application.Change; +import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId; import com.yahoo.vespa.hosted.controller.deployment.ConvergenceSummary; import com.yahoo.vespa.hosted.controller.deployment.DeploymentStatus; @@ -363,12 +365,6 @@ class JobControllerApiHandlerHelper { stepObject.setString("environment", job.type().environment().value()); if ( ! job.type().environment().isTest()) { stepObject.setString("region", job.type().zone().value()); - var deployment = application.require(job.application().instance()).deployments().get(job.type().zone()); - var cloudAccount = deployment == null ? null : deployment.cloudAccount(); - if (cloudAccount != null && controller.zoneRegistry().isExternal(cloudAccount)) { - var enclaveObject = stepObject.setObject("enclave"); - enclaveObject.setString("cloudAccount", cloudAccount.value()); - } } if (job.type().isProduction() && job.type().isDeployment()) { @@ -395,6 +391,12 @@ class JobControllerApiHandlerHelper { toSlime(runObject.setObject("versions"), versions.versions(), application); } + if ( ! jobStatus.runs().isEmpty()) + controller.applications().decideCloudAccountOf(new DeploymentId(job.application(), + jobStatus.runs().lastEntry().getValue().id().job().type().zone()), // Urgh, must use a job with actual zone. + status.application().deploymentSpec()) + .ifPresent(cloudAccount -> stepObject.setObject("enclave").setString("cloudAccount", cloudAccount.value())); + toSlime(stepObject.setArray("runs"), jobStatus.runs().descendingMap().values(), application, 10, baseUriForJob); } stepObject.setString("delayCause", diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java index feb8a89b057..4e3a8b7caf0 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java @@ -5,6 +5,7 @@ import com.yahoo.component.Version; import com.yahoo.config.application.api.DeploymentInstanceSpec; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.CloudAccount; import com.yahoo.container.jdisc.EmptyResponse; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; @@ -16,10 +17,13 @@ import com.yahoo.restapi.UriBuilder; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; import com.yahoo.vespa.hosted.controller.Controller; +import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobId; 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.Change; +import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId; import com.yahoo.vespa.hosted.controller.deployment.DeploymentStatus; import com.yahoo.vespa.hosted.controller.deployment.DeploymentStatus.DelayCause; @@ -178,7 +182,7 @@ public class DeploymentApiHandler extends ThreadedHttpRequestHandler { if (stepStatus != null) { // Instance may not have any steps, i.e. an empty deployment spec has been submitted Readiness platformReadiness = stepStatus.blockedUntil(Change.of(statistics.version())); if (platformReadiness.cause() == DelayCause.changeBlocked) - instanceObject.setLong("blockedUntil", platformReadiness.at().toEpochMilli()); + instanceObject.setLong("blockedUntil", platformReadiness.at().toEpochMilli()); } instanceObject.setString("upgradePolicy", toString(status.application().deploymentSpec().instance(instance.instance()) .map(DeploymentInstanceSpec::upgradePolicy) @@ -213,10 +217,13 @@ public class DeploymentApiHandler extends ThreadedHttpRequestHandler { runs.forEach((type, rs) -> { Cursor runObject = allRunsObject.setObject(type.jobName()); Cursor upgradeObject = upgradeRunsObject.setObject(type.jobName()); + CloudAccount cloudAccount = controller.applications().decideCloudAccountOf(new DeploymentId(instance, type.zone()), + status.application().deploymentSpec()) + .orElse(null); for (RunInfo run : rs) { - toSlime(runObject, run.run); + toSlime(runObject, run.run, cloudAccount); if (run.upgrade) - toSlime(upgradeObject, run.run); + toSlime(upgradeObject, run.run, cloudAccount); } }); }); @@ -227,13 +234,14 @@ public class DeploymentApiHandler extends ThreadedHttpRequestHandler { return new SlimeJsonResponse(slime); } - private void toSlime(Cursor jobObject, Run run) { + private void toSlime(Cursor jobObject, Run run, CloudAccount cloudAccount) { String key = run.hasFailed() ? "failing" : run.hasEnded() ? "success" : "running"; Cursor runObject = jobObject.setObject(key); runObject.setLong("number", run.id().number()); runObject.setLong("start", run.start().toEpochMilli()); run.end().ifPresent(end -> runObject.setLong("end", end.toEpochMilli())); runObject.setString("status", nameOf(run.status())); + if (cloudAccount != null) runObject.setObject("enclave").setString("cloudAccount", cloudAccount.value()); } private void toSlime(Cursor object, ApplicationId id, HttpRequest request) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/overview-enclave.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/overview-enclave.json index 6a322f9f381..3673c1bdf07 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/overview-enclave.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/overview-enclave.json @@ -221,9 +221,6 @@ "url": "https://some.url:43/instance/default/job/production-aws-us-east-1c", "environment": "prod", "region": "prod.aws-us-east-1c", - "enclave": { - "cloudAccount": "aws:123456789012" - }, "currentPlatform": "6.1.0", "currentApplication": { "build": 1, @@ -232,6 +229,9 @@ "commit": "commit1" }, "toRun": [ ], + "enclave": { + "cloudAccount": "aws:123456789012" + }, "runs": [ { "id": 1, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java index bcc1f27c89f..eea5c9bdccf 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java @@ -3,8 +3,11 @@ package com.yahoo.vespa.hosted.controller.restapi.deployment; import com.yahoo.component.Version; import com.yahoo.config.application.api.ValidationId; +import com.yahoo.config.provision.CloudAccount; import com.yahoo.config.provision.HostName; +import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.zone.ZoneId; +import com.yahoo.vespa.flags.PermanentFlags; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.application.pkg.ApplicationPackage; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -34,6 +37,10 @@ public class DeploymentApiTest extends ControllerContainerTest { void testDeploymentApi() { ContainerTester tester = new ContainerTester(container, responseFiles); DeploymentTester deploymentTester = new DeploymentTester(new ControllerTester(tester)); + + CloudAccount cloudAccount = CloudAccount.from("aws:123456789012"); + deploymentTester.controllerTester().flagSource().withListFlag(PermanentFlags.CLOUD_ACCOUNTS.id(), List.of(cloudAccount.value()), String.class); + deploymentTester.controllerTester().zoneRegistry().configureCloudAccount(cloudAccount, ZoneId.from("prod.aws-us-east-1a")); Version version = Version.fromString("4.9"); deploymentTester.controllerTester().upgradeSystem(version); ApplicationPackage multiInstancePackage = new ApplicationPackageBuilder() @@ -41,7 +48,7 @@ public class DeploymentApiTest extends ControllerContainerTest { .region("us-west-1") .build(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() - .region("us-west-1") + .region("aws-us-east-1a", cloudAccount.value()) .build(); ApplicationPackage emptyPackage = new ApplicationPackageBuilder().instances("default") .allow(ValidationId.deploymentRemoval) diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json index ac43fbf2a80..978258a31a6 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json @@ -50,26 +50,32 @@ "coolingDownUntil": 1600022201500 }, { - "name": "production-us-west-1" + "name": "production-aws-us-east-1a" } ], "allRuns": { - "production-us-west-1": { + "production-aws-us-east-1a": { "success": { "number": 1, "start": 1600000000000, "end": 1600000000000, - "status": "success" + "status": "success", + "enclave": { + "cloudAccount": "aws:123456789012" + } } } }, "upgradeRuns": { - "production-us-west-1": { + "production-aws-us-east-1a": { "success": { "number": 1, "start": 1600000000000, "end": 1600000000000, - "status": "success" + "status": "success", + "enclave": { + "cloudAccount": "aws:123456789012" + } } } } @@ -198,7 +204,7 @@ "pending": "platform" }, { - "name": "production-us-west-1", + "name": "production-aws-us-east-1a", "pending": "platform" } ], |