diff options
author | Valerij Fredriksen <valerijf@yahooinc.com> | 2023-03-29 14:15:51 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@yahooinc.com> | 2023-03-29 14:35:01 +0200 |
commit | 468844f6de586f30aa468ee6596f201fe61e63d6 (patch) | |
tree | cbdfa47b2fa679d9debe474c3d2e7ed26c22fd6f /controller-server | |
parent | 8a6690869765a8f2664fd601150d1722fc1f4c99 (diff) |
Revert "Add API to list zones"
This reverts commit 538f72529022e703aea37c3baec7eba5403aedfd.
Diffstat (limited to 'controller-server')
5 files changed, 0 insertions, 154 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/CloudInfoApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/CloudInfoApiHandler.java deleted file mode 100644 index 338bc29269a..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/CloudInfoApiHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.restapi.cloudinfo; - -import com.yahoo.container.jdisc.HttpRequest; -import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.jdisc.ThreadedHttpRequestHandler; -import com.yahoo.restapi.ErrorResponse; -import com.yahoo.restapi.Path; -import com.yahoo.restapi.ResourceResponse; -import com.yahoo.restapi.SlimeJsonResponse; -import com.yahoo.slime.Cursor; -import com.yahoo.slime.Slime; -import com.yahoo.vespa.hosted.controller.api.integration.ServiceRegistry; -import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry; -import com.yahoo.vespa.hosted.controller.restapi.ErrorResponses; -import com.yahoo.yolean.Exceptions; - -/** - * Read-only REST API that provides information about cloud resources (e.g. zones and flavors). - * - * @author freva - */ -@SuppressWarnings("unused") -public class CloudInfoApiHandler extends ThreadedHttpRequestHandler { - - private final ZoneRegistry zoneRegistry; - - public CloudInfoApiHandler(Context parentCtx, ServiceRegistry serviceRegistry) { - super(parentCtx); - this.zoneRegistry = serviceRegistry.zoneRegistry(); - } - - @Override - public HttpResponse handle(HttpRequest request) { - try { - return switch (request.getMethod()) { - case GET -> get(request); - default -> ErrorResponse.methodNotAllowed("Method '" + request.getMethod() + "' is unsupported"); - }; - } catch (IllegalArgumentException e) { - return ErrorResponse.badRequest(Exceptions.toMessageString(e)); - } catch (RuntimeException e) { - return ErrorResponses.logThrowing(request, log, e); - } - } - - private HttpResponse get(HttpRequest request) { - Path path = new Path(request.getUri()); - if (path.matches("/cloudinfo/v1")) return new ResourceResponse(request, "zones"); - if (path.matches("/cloudinfo/v1/zones")) return zones(request); - return notFound(path); - } - - private HttpResponse zones(HttpRequest request) { - Slime slime = new Slime(); - Cursor zones = slime.setObject().setArray("zones"); - zoneRegistry.zones().publiclyVisible().all().zones().forEach(zone -> { - Cursor object = zones.addObject(); - object.setString("environment", zone.getEnvironment().value()); - object.setString("region", zone.getRegionName().value()); - object.setString("cloud", zone.getCloudName().value()); - object.setString("availabilityZone", zone.getCloudNativeAvailabilityZone()); - }); - return new SlimeJsonResponse(slime); - } - - private HttpResponse notFound(Path path) { - return ErrorResponse.notFoundError("Nothing at " + path); - } - -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java index 30f74f4bf70..7522f42f91b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java @@ -96,9 +96,6 @@ public class ControllerContainerTest { <handler id='com.yahoo.vespa.hosted.controller.restapi.os.OsApiHandler'> <binding>http://localhost/os/v1/*</binding> </handler> - <handler id='com.yahoo.vespa.hosted.controller.restapi.cloudinfo.CloudInfoApiHandler'> - <binding>http://localhost/cloudinfo/v1/*</binding> - </handler> <handler id='com.yahoo.vespa.hosted.controller.restapi.zone.v2.ZoneApiHandler'> <binding>http://localhost/zone/v2</binding> <binding>http://localhost/zone/v2/*</binding> diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/CloudInfoApiHandlerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/CloudInfoApiHandlerTest.java deleted file mode 100644 index c4ce687504e..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/CloudInfoApiHandlerTest.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.restapi.cloudinfo; - -import com.yahoo.config.provision.CloudName; -import com.yahoo.config.provision.SystemName; -import com.yahoo.config.provision.zone.ZoneApi; -import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; -import com.yahoo.vespa.hosted.controller.restapi.ContainerTester; -import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.io.File; - -/** - * @author freva - */ -class CloudInfoApiHandlerTest extends ControllerContainerTest { - private static final String responses = "src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/responses/"; - - private ContainerTester tester; - - @Override - protected SystemName system() { - return SystemName.cd; - } - - @BeforeEach - public void before() { - tester = new ContainerTester(container, responses); - tester.serviceRegistry().zoneRegistry().setZones( - zone(CloudName.AWS, "prod", "aws-us-east-1a", "use1-az1"), - zone(CloudName.AWS, "prod", "aws-us-west-2c", "usw2-az4"), - zone(CloudName.GCP, "prod", "gcp-us-east1-f", "us-east1-f")); - } - - @Test - void test_api() { - tester.assertResponse(authenticatedRequest("http://localhost:8080/cloudinfo/v1/"), new File("root.json")); - tester.assertResponse(authenticatedRequest("http://localhost:8080/cloudinfo/v1/zones"), new File("zones.json")); - } - - private static ZoneApi zone(CloudName cloudName, String environment, String region, String availabilityZone) { - return ZoneApiMock.newBuilder() - .with(cloudName) - .with(ZoneId.from(environment, region)) - .withCloudNativeAvailabilityZone(availabilityZone) - .build(); - } -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/responses/root.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/responses/root.json deleted file mode 100644 index a733018428e..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/responses/root.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "resources": [ - { - "url": "http://localhost:8080/cloudinfo/v1/zones/" - } - ] -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/responses/zones.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/responses/zones.json deleted file mode 100644 index d884b2c06a3..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cloudinfo/responses/zones.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "zones": [ - { - "environment": "prod", - "region": "aws-us-east-1a", - "cloud": "aws", - "availabilityZone": "use1-az1" - }, - { - "environment": "prod", - "region": "aws-us-west-2c", - "cloud": "aws", - "availabilityZone": "usw2-az4" - }, - { - "environment": "prod", - "region": "gcp-us-east1-f", - "cloud": "gcp", - "availabilityZone": "us-east1-f" - } - ] -} |