summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java8
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java13
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java5
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java12
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java69
8 files changed, 84 insertions, 33 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 3eb00a0adef..0557fa6e552 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -483,6 +483,10 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return getLocalSession(tenant, sessionId).getApplicationFile(Path.fromString(path), mode);
}
+ public Tenant getTenant(ApplicationId applicationId) {
+ return tenantRepository.getTenant(applicationId.tenant());
+ }
+
private Application getApplication(ApplicationId applicationId) {
return getApplication(applicationId, Optional.empty());
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java
index 41119077b28..12353c0e7e3 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java
@@ -96,4 +96,12 @@ public final class ApplicationSet {
return new ArrayList<>(applications.values());
}
+ public List<Version> getAllVersions(ApplicationId applicationId) {
+ return applications.values().stream()
+ .filter(application -> application.getId().equals(applicationId))
+ .map(Application::getVespaVersion)
+ .sorted()
+ .collect(Collectors.toList());
+ }
+
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
index 3c909730902..d1861184c24 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
@@ -15,13 +15,16 @@ import com.yahoo.io.IOUtils;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.application.BindingMatch;
import com.yahoo.jdisc.application.UriPattern;
+import com.yahoo.slime.Cursor;
import com.yahoo.vespa.config.server.ApplicationRepository;
+import com.yahoo.vespa.config.server.application.ApplicationSet;
import com.yahoo.vespa.config.server.http.ContentHandler;
import com.yahoo.vespa.config.server.http.ContentRequest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.HttpHandler;
import com.yahoo.vespa.config.server.http.JSONResponse;
import com.yahoo.vespa.config.server.http.NotFoundException;
+import com.yahoo.vespa.config.server.tenant.Tenant;
import java.io.IOException;
import java.time.Duration;
@@ -151,7 +154,11 @@ public class ApplicationHandler extends HttpHandler {
}
}
- return new GetApplicationResponse(Response.Status.OK, applicationRepository.getApplicationGeneration(applicationId));
+ Tenant tenant = applicationRepository.getTenant(applicationId);
+ Optional<ApplicationSet> applicationSet = applicationRepository.getCurrentActiveApplicationSet(tenant, applicationId);
+ return new GetApplicationResponse(Response.Status.OK,
+ applicationRepository.getApplicationGeneration(applicationId),
+ applicationSet.get().getAllVersions(applicationId));
}
@Override
@@ -309,9 +316,11 @@ public class ApplicationHandler extends HttpHandler {
}
private static class GetApplicationResponse extends JSONResponse {
- GetApplicationResponse(int status, long generation) {
+ GetApplicationResponse(int status, long generation, List<Version> modelVersions) {
super(status);
object.setLong("generation", generation);
+ Cursor modelVersionArray = object.setArray("modelVersions");
+ modelVersions.forEach(version -> modelVersionArray.addString(version.toFullString()));
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
index f182a28ab70..e3f4854105a 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.session;
import java.util.Optional;
@@ -17,6 +17,7 @@ import java.util.logging.Logger;
* The session must be in the session repo.
*
* @author Vegard Havdal
+ * @author hmusum
*/
public class SessionStateWatcher {
@@ -42,8 +43,8 @@ public class SessionStateWatcher {
this.remoteSession = remoteSession;
this.localSession = localSession;
this.metrics = metrics;
- this.fileCache.start();
this.fileCache.addListener(this::nodeChanged);
+ this.fileCache.start();
this.zkWatcherExecutor = zkWatcherExecutor;
this.sessionRepository = sessionRepository;
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java
index 7a9a4f950b5..90bcc221476 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java
@@ -93,8 +93,8 @@ public class Tenant implements TenantHandlerProvider {
* Called by watchers as a reaction to deleting a tenant.
*/
void close() {
- applicationRepo.close(); // Closes watchers.
- sessionRepository.close(); // Closes watchers, clears memory, and deletes local files and ZK session state.
+ applicationRepo.close(); // Closes watchers.
+ sessionRepository.close(); // Closes watchers, clears memory, and deletes local files and ZK session state.
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java
index c7ec2657996..685856d5cf8 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java
@@ -42,7 +42,7 @@ import java.util.Optional;
*/
public class ZKApplicationPackage implements ApplicationPackage {
- private ZKApplication zkApplication;
+ private final ZKApplication zkApplication;
private final Map<Version, PreGeneratedFileRegistry> fileRegistryMap = new HashMap<>();
private final Optional<AllocatedHosts> allocatedHosts;
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java
index cf1e00674cb..f5d661e265a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java
@@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.component.Version;
@@ -21,8 +22,8 @@ import static org.junit.Assert.assertEquals;
public class ApplicationSetTest {
private ApplicationSet applicationSet;
- private List<Version> vespaVersions = new ArrayList<>();
- private List<Application> applications = new ArrayList<>();
+ private final List<Version> vespaVersions = new ArrayList<>();
+ private final List<Application> applications = new ArrayList<>();
@Before
public void setUp() {
@@ -50,6 +51,13 @@ public class ApplicationSetTest {
applicationSet.getForVersionOrLatest(Optional.of(vespaVersions.get(1)), Instant.now());
}
+ @Test
+ public void testGetAllVersions() {
+ applicationSet = ApplicationSet.fromList(applications);
+ assertEquals(List.of(Version.fromString("1.2.3"), Version.fromString("1.2.4"), Version.fromString("1.2.5")),
+ applicationSet.getAllVersions(ApplicationId.defaultId()));
+ }
+
private Application createApplication(Version version) {
return new Application(new ModelStub(), null, 0, false, version, MetricUpdater.createTestUpdater(), ApplicationId.defaultId());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
index 06e404bee32..3438fbecc59 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
@@ -3,6 +3,8 @@ package com.yahoo.vespa.config.server.http.v2;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yahoo.cloud.config.ConfigserverConfig;
+import com.yahoo.component.Version;
+import com.yahoo.config.model.api.ModelFactory;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationName;
import com.yahoo.config.provision.InstanceName;
@@ -19,11 +21,13 @@ import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.ConfigConvergenceChecker;
import com.yahoo.vespa.config.server.application.HttpProxy;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
+import com.yahoo.vespa.config.server.deploy.DeployTester;
import com.yahoo.vespa.config.server.deploy.InfraDeployerProvider;
import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
import com.yahoo.vespa.config.server.http.StaticResponse;
+import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.provision.HostProvisionerProvider;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.tenant.Tenant;
@@ -40,8 +44,10 @@ import java.io.InputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.time.Clock;
+import java.util.List;
import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER;
+import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
import static com.yahoo.vespa.config.server.http.SessionHandlerTest.getRenderedString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -66,6 +72,7 @@ public class ApplicationHandlerTest {
private final static NullMetric metric = new NullMetric();
private final static ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder());
private static final MockLogRetriever logRetriever = new MockLogRetriever();
+ private static final Version vespaVersion = Version.fromString("7.8.9");
private TenantRepository tenantRepository;
private ApplicationRepository applicationRepository;
@@ -75,7 +82,11 @@ public class ApplicationHandlerTest {
@Before
public void setup() {
- TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().provisioner(provisioner).build();
+ List<ModelFactory> modelFactories = List.of(DeployTester.createModelFactory(vespaVersion));
+ TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder()
+ .provisioner(provisioner)
+ .modelFactoryRegistry(new ModelFactoryRegistry(modelFactories))
+ .build();
tenantRepository = new TenantRepository(componentRegistry, false);
tenantRepository.addTenant(mytenantName);
provisioner = new SessionHandlerTest.MockProvisioner();
@@ -149,9 +160,14 @@ public class ApplicationHandlerTest {
@Test
public void testGet() throws Exception {
- long sessionId = applicationRepository.deploy(testApp, prepareParams(applicationId)).sessionId();
- assertApplicationGeneration(applicationId, Zone.defaultZone(), sessionId, true);
- assertApplicationGeneration(applicationId, Zone.defaultZone(), sessionId, false);
+ PrepareParams prepareParams = new PrepareParams.Builder()
+ .applicationId(applicationId)
+ .vespaVersion(vespaVersion)
+ .build();
+ long sessionId = applicationRepository.deploy(testApp, prepareParams).sessionId();
+
+ assertApplicationResponse(applicationId, Zone.defaultZone(), sessionId, true, vespaVersion);
+ assertApplicationResponse(applicationId, Zone.defaultZone(), sessionId, false, vespaVersion);
}
@Test
@@ -196,7 +212,7 @@ public class ApplicationHandlerTest {
when(mockHttpProxy.get(any(), eq(host), eq(CLUSTERCONTROLLER_CONTAINER.serviceName),eq("clustercontroller-status/v1/clusterName1")))
.thenReturn(new StaticResponse(200, "text/html", "<html>...</html>"));
- HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, GET));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>...</html>");
}
@@ -229,7 +245,7 @@ public class ApplicationHandlerTest {
String url = toUrlPath(applicationId, Zone.defaultZone(), true) + "/logs?from=100&to=200";
ApplicationHandler mockHandler = createApplicationHandler();
- HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, GET));
assertEquals(200, response.getStatus());
assertEquals("log line", getRenderedString(response));
@@ -240,7 +256,7 @@ public class ApplicationHandlerTest {
applicationRepository.deploy(testApp, prepareParams(applicationId));
String url = toUrlPath(applicationId, Zone.defaultZone(), true) + "/tester/status";
ApplicationHandler mockHandler = createApplicationHandler();
- HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, GET));
assertEquals(200, response.getStatus());
assertEquals("OK", getRenderedString(response));
}
@@ -251,7 +267,7 @@ public class ApplicationHandlerTest {
String url = toUrlPath(applicationId, Zone.defaultZone(), true) + "/tester/log?after=1234";
ApplicationHandler mockHandler = createApplicationHandler();
- HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, GET));
assertEquals(200, response.getStatus());
assertEquals("log", getRenderedString(response));
}
@@ -273,7 +289,7 @@ public class ApplicationHandlerTest {
applicationRepository.deploy(testApp, prepareParams(applicationId));
String url = toUrlPath(applicationId, Zone.defaultZone(), true) + "/tester/ready";
ApplicationHandler mockHandler = createApplicationHandler();
- HttpRequest testRequest = HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET);
+ HttpRequest testRequest = HttpRequest.createTestRequest(url, GET);
HttpResponse response = mockHandler.handle(testRequest);
assertEquals(200, response.getStatus());
}
@@ -315,13 +331,14 @@ public class ApplicationHandlerTest {
}
}
- private void assertApplicationGeneration(ApplicationId applicationId, Zone zone, long expectedGeneration, boolean fullAppIdInUrl) throws IOException {
- assertApplicationGeneration(toUrlPath(applicationId, zone, fullAppIdInUrl), expectedGeneration);
+ private void assertApplicationResponse(ApplicationId applicationId, Zone zone, long expectedGeneration,
+ boolean fullAppIdInUrl, Version expectedVersion) throws IOException {
+ assertApplicationResponse(toUrlPath(applicationId, zone, fullAppIdInUrl), expectedGeneration, expectedVersion);
}
private void assertSuspended(boolean expectedValue, ApplicationId application, Zone zone) throws IOException {
String restartUrl = toUrlPath(application, zone, true) + "/suspended";
- HttpResponse response = createApplicationHandler().handle(HttpRequest.createTestRequest(restartUrl, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ HttpResponse response = createApplicationHandler().handle(HttpRequest.createTestRequest(restartUrl, GET));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "{\"suspended\":" + expectedValue + "}");
}
@@ -332,24 +349,28 @@ public class ApplicationHandlerTest {
return url;
}
- private void assertApplicationGeneration(String url, long expectedGeneration) throws IOException {
- HttpResponse response = createApplicationHandler().handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
- HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "{\"generation\":" + expectedGeneration + "}");
+ private void assertApplicationResponse(String url, long expectedGeneration, Version expectedVersion) throws IOException {
+ HttpResponse response = createApplicationHandler().handle(HttpRequest.createTestRequest(url, GET));
+ assertEquals(200, response.getStatus());
+ String renderedString = SessionHandlerTest.getRenderedString(response);
+ assertEquals("{\"generation\":" + expectedGeneration + ",\"modelVersions\":[\"" + expectedVersion.toFullString() + "\"]}", renderedString);
}
private void assertApplicationExists(ApplicationId applicationId, Zone zone) throws IOException {
- String tenantName = applicationId == null ? null : applicationId.tenant().value();
- String expected = applicationId == null ? "[]" : "[\"http://myhost:14000/application/v2/tenant/" + tenantName + "/application/" + applicationId.application().value() +
- "/environment/" + zone.environment().value() +
- "/region/" + zone.region().value() +
- "/instance/" + applicationId.instance().value() + "\"]";
+ String tenantName = applicationId.tenant().value();
+ String expected = "[\"http://myhost:14000/application/v2/tenant/" +
+ tenantName + "/application/" + applicationId.application().value() +
+ "/environment/" + zone.environment().value() +
+ "/region/" + zone.region().value() +
+ "/instance/" + applicationId.instance().value() + "\"]";
ListApplicationsHandler listApplicationsHandler = new ListApplicationsHandler(ListApplicationsHandler.testOnlyContext(),
tenantRepository,
Zone.defaultZone());
- ListApplicationsHandlerTest.assertResponse(listApplicationsHandler, "http://myhost:14000/application/v2/tenant/" + tenantName + "/application/",
+ ListApplicationsHandlerTest.assertResponse(listApplicationsHandler,
+ "http://myhost:14000/application/v2/tenant/" + tenantName + "/application/",
Response.Status.OK,
expected,
- com.yahoo.jdisc.http.HttpRequest.Method.GET);
+ GET);
}
private void restart(ApplicationId application, Zone zone) throws IOException {
@@ -360,13 +381,13 @@ public class ApplicationHandlerTest {
private void converge(ApplicationId application, Zone zone) throws IOException {
String convergeUrl = toUrlPath(application, zone, true) + "/serviceconverge";
- HttpResponse response = createApplicationHandler().handle(HttpRequest.createTestRequest(convergeUrl, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ HttpResponse response = createApplicationHandler().handle(HttpRequest.createTestRequest(convergeUrl, GET));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "");
}
private HttpResponse fileDistributionStatus(ApplicationId application, Zone zone) {
String restartUrl = toUrlPath(application, zone, true) + "/filedistributionstatus";
- return createApplicationHandler().handle(HttpRequest.createTestRequest(restartUrl, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ return createApplicationHandler().handle(HttpRequest.createTestRequest(restartUrl, GET));
}
private static class MockStateApiFactory implements ConfigConvergenceChecker.StateApiFactory {