summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2019-05-31 11:35:43 +0200
committerHarald Musum <musum@verizonmedia.com>2019-05-31 11:35:43 +0200
commite53edf7b1dad97a96942da267e26dd9a28a9c5d0 (patch)
treed245eda35e04d425d0b77bb1f481dbcf48c828b5 /configserver
parent530df929b49dc0285ee31fa74c1bcfc908f787f1 (diff)
Add support for checking config convergence for a specific vespa version
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java16
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java14
3 files changed, 26 insertions, 7 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 3aea22ce8b2..0ceec0ab00b 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
@@ -451,12 +451,16 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
private Application getApplication(ApplicationId applicationId) {
+ return getApplication(applicationId, Optional.empty());
+ }
+
+ private Application getApplication(ApplicationId applicationId, Optional<Version> version) {
try {
Tenant tenant = tenantRepository.getTenant(applicationId.tenant());
if (tenant == null) throw new IllegalArgumentException("Tenant '" + applicationId.tenant() + "' not found");
long sessionId = getSessionIdForApplication(tenant, applicationId);
RemoteSession session = tenant.getRemoteSessionRepo().getSession(sessionId, 0);
- return session.ensureApplicationLoaded().getForVersionOrLatest(Optional.empty(), clock.instant());
+ return session.ensureApplicationLoaded().getForVersionOrLatest(version, clock.instant());
} catch (Exception e) {
log.log(LogLevel.WARNING, "Failed getting application for '" + applicationId + "'", e);
throw e;
@@ -500,12 +504,14 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
// ---------------- Convergence ----------------------------------------------------------------
- public HttpResponse checkServiceForConfigConvergence(ApplicationId applicationId, String hostAndPort, URI uri, Duration timeout) {
- return convergeChecker.checkService(getApplication(applicationId), hostAndPort, uri, timeout);
+ public HttpResponse checkServiceForConfigConvergence(ApplicationId applicationId, String hostAndPort, URI uri,
+ Duration timeout, Optional<Version> vespaVersion) {
+ return convergeChecker.checkService(getApplication(applicationId, vespaVersion), hostAndPort, uri, timeout);
}
- public HttpResponse servicesToCheckForConfigConvergence(ApplicationId applicationId, URI uri, Duration timeoutPerService) {
- return convergeChecker.servicesToCheck(getApplication(applicationId), uri, timeoutPerService);
+ public HttpResponse servicesToCheckForConfigConvergence(ApplicationId applicationId, URI uri,
+ Duration timeoutPerService, Optional<Version> vespaVersion) {
+ return convergeChecker.servicesToCheck(getApplication(applicationId, vespaVersion), uri, timeoutPerService);
}
// ---------------- Logs ----------------------------------------------------------------
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java
index 4fbda42fdc7..97c1c9c89b0 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java
@@ -8,6 +8,7 @@ import com.yahoo.config.model.api.HostInfo;
import com.yahoo.config.model.api.PortInfo;
import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.log.LogLevel;
import com.yahoo.slime.Cursor;
import com.yahoo.vespa.config.server.http.JSONResponse;
import org.glassfish.jersey.client.ClientProperties;
@@ -43,6 +44,7 @@ import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER
*/
public class ConfigConvergenceChecker extends AbstractComponent {
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(ConfigConvergenceChecker.class.getName());
private static final ApplicationId routingApplicationId = ApplicationId.from("hosted-vespa", "routing", "default");
private static final String statePath = "/state/v1/";
private static final String configSubPath = "config";
@@ -68,6 +70,7 @@ public class ConfigConvergenceChecker extends AbstractComponent {
/** Check all services in given application. Returns the minimum current generation of all services */
public ServiceListResponse servicesToCheck(Application application, URI requestUrl, Duration timeoutPerService) {
+ log.log(LogLevel.INFO, "Finding services to check config convergence for in '" + application);
List<ServiceInfo> servicesToCheck = new ArrayList<>();
application.getModel().getHosts()
.forEach(host -> host.getServices().stream()
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 e04f83cc648..d9592dc9352 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
@@ -2,6 +2,7 @@
package com.yahoo.vespa.config.server.http.v2;
import com.google.inject.Inject;
+import com.yahoo.component.Version;
import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationName;
@@ -62,7 +63,8 @@ public class ApplicationHandler extends HttpHandler {
if (isServiceConvergeRequest(request)) {
// Expects both hostname and port in the request (hostname:port)
String hostAndPort = getHostNameFromRequest(request);
- return applicationRepository.checkServiceForConfigConvergence(applicationId, hostAndPort, request.getUri(), timeout);
+ return applicationRepository.checkServiceForConfigConvergence(applicationId, hostAndPort, request.getUri(),
+ timeout, getVespaVersionFromRequest(request));
}
if (isClusterControllerStatusRequest(request)) {
@@ -89,7 +91,8 @@ public class ApplicationHandler extends HttpHandler {
}
if (isServiceConvergeListRequest(request)) {
- return applicationRepository.servicesToCheckForConfigConvergence(applicationId, request.getUri(), timeout);
+ return applicationRepository.servicesToCheckForConfigConvergence(applicationId, request.getUri(), timeout,
+ getVespaVersionFromRequest(request));
}
if (isFiledistributionStatusRequest(request)) {
@@ -225,6 +228,13 @@ public class ApplicationHandler extends HttpHandler {
.build();
}
+ private static Optional<Version> getVespaVersionFromRequest(HttpRequest request) {
+ String vespaVersion = request.getProperty("vespaVersion");
+ return (vespaVersion == null || vespaVersion.isEmpty())
+ ? Optional.empty()
+ : Optional.of(Version.fromString(vespaVersion));
+ }
+
private static class DeleteApplicationResponse extends JSONResponse {
DeleteApplicationResponse(int status, ApplicationId applicationId) {
super(status);