diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2021-06-28 21:54:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-28 21:54:50 +0200 |
commit | dfa07c1710906646b6474b10e59a71600a162a8b (patch) | |
tree | 8036e52a7333942703d89fb31d1abef1787a24a9 | |
parent | 06211ee2fbf11a53358b30370cd127e2a9764f07 (diff) | |
parent | d1e465781a15237b2c3033d80c6fbaae59b4ef9b (diff) |
Merge pull request #18426 from vespa-engine/freva/include-empty-apps
Include empty applications in recursive tenant
5 files changed, 39 insertions, 5 deletions
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 1510bb05a62..4041693ee55 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 @@ -128,6 +128,7 @@ import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.Base64; +import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedHashSet; @@ -2094,8 +2095,13 @@ public class ApplicationApiHandler extends AuditLoggingRequestHandler { Cursor applicationArray = object.setArray("applications"); for (Application application : applications) { DeploymentStatus status = null; - for (Instance instance : showOnlyProductionInstances(request) ? application.productionInstances().values() - : application.instances().values()) { + Collection<Instance> instances = showOnlyProductionInstances(request) ? application.productionInstances().values() + : application.instances().values(); + + if (instances.isEmpty() && !showOnlyActiveInstances(request)) + toSlime(application.id(), applicationArray.addObject(), request); + + for (Instance instance : instances) { if (showOnlyActiveInstances(request) && instance.deployments().isEmpty()) continue; if (recurseOverApplications(request)) { 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 ed81ce36600..3fa593fcf64 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 @@ -233,7 +233,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .userIdentity(USER_ID) .properties(Map.of("recursive", "true", "production", "true")), - new File("tenant-without-applications.json")); + new File("tenant-with-empty-application.json")); // GET at an application, with "&recursive=true&production=true", recurses over no instances yet, as they are not in deployment spec. tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1", GET) .userIdentity(USER_ID) diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant-with-empty-application.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant-with-empty-application.json new file mode 100644 index 00000000000..58c76b8227e --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant-with-empty-application.json @@ -0,0 +1,16 @@ +{ + "tenant": "tenant1", + "type": "ATHENS", + "athensDomain": "domain1", + "property": "property1", + "applications": [ + { + "tenant": "tenant1", + "application": "application1", + "url": "http://localhost:8080/application/v4/tenant/tenant1/application/application1" + } + ], + "metaData":{ + "createdAtMillis": "(ignore)" + } +} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-keys.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-keys.json index 03e5eb2b7a8..7cc1a51a114 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-keys.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-keys.json @@ -22,7 +22,13 @@ "budgetUsed": 0.0, "clusterSize": 5 }, - "applications": [], + "applications": [ + { + "tenant": "my-tenant", + "application": "my-app", + "url": "http://localhost:8080/application/v4/tenant/my-tenant/application/my-app" + } + ], "metaData":{ "createdAtMillis": "(ignore)" } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-secrets.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-secrets.json index dc717b5cac0..1662484ade8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-secrets.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-with-secrets.json @@ -31,7 +31,13 @@ "budgetUsed": 0.0, "clusterSize": 5 }, - "applications": [], + "applications": [ + { + "tenant": "my-tenant", + "application": "my-app", + "url": "http://localhost:8080/application/v4/tenant/my-tenant/application/my-app" + } + ], "metaData": { "createdAtMillis": "(ignore)" } |