summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@yahoo-inc.com>2017-01-25 10:36:23 +0100
committerHarald Musum <musum@yahoo-inc.com>2017-01-25 10:36:23 +0100
commit7b806f6b5d02f98a721db8f44abd7892a804fa8e (patch)
tree4f21f4f645f222419730628a5a77411b06c5f5b4 /configserver
parent6a53db7420b068a48dd8df3142d2df1735bc5c28 (diff)
Remove unused code (API has been replaced by /serviceconverge)
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java6
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceChecker.java57
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java44
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java6
5 files changed, 3 insertions, 126 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 8e706b7056a..4512042e857 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
@@ -34,7 +34,6 @@ import com.yahoo.vespa.config.server.tenant.Tenants;
import com.yahoo.vespa.curator.Curator;
import java.io.File;
-import java.io.IOException;
import java.net.URI;
import java.time.Clock;
import java.time.Duration;
@@ -155,11 +154,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return convergeChecker.nodeConvergenceCheck(application, hostname, uri);
}
- public void waitForConfigConverged(Tenant tenant, ApplicationId applicationId, TimeoutBudget timeoutBudget) throws IOException {
- Application application = getApplication(tenant, applicationId);
- convergeChecker.waitForConfigConverged(application, timeoutBudget);
- }
-
public HttpResponse listConfigConvergence(Tenant tenant, ApplicationId applicationId, URI uri) {
Application application = getApplication(tenant, applicationId);
return convergeChecker.listConfigConvergence(application, uri);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceChecker.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceChecker.java
index 91376746341..675af7ff706 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceChecker.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceChecker.java
@@ -6,7 +6,6 @@ import com.google.inject.Inject;
import com.yahoo.cloud.config.ModelConfig;
import com.yahoo.component.AbstractComponent;
import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.http.HttpConfigResponse;
import org.glassfish.jersey.client.proxy.WebResourceFactory;
import org.json.JSONArray;
@@ -33,7 +32,6 @@ import java.util.*;
public class ApplicationConvergenceChecker extends AbstractComponent {
private static final String statePath = "/state/v1/";
private static final String configSubPath = "config";
- private static final String configPath = statePath + configSubPath;
private final StateApiFactory stateApiFactory;
private final Client client = ClientBuilder.newClient();
@@ -56,66 +54,13 @@ public class ApplicationConvergenceChecker extends AbstractComponent {
this.stateApiFactory = stateApiFactory;
}
- // TODO: Remove this function once the other has taken over (list)
- private void waitForConfigConverged(ModelConfig config, long wantedGeneration, TimeoutBudget timeoutBudget) {
-
- config.hosts().stream()
- .forEach(host -> host.services().stream()
- .filter(service -> serviceTypes.contains(service.type()))
- .forEach(service -> {
- Optional<Integer> statePort = getStatePort(service);
- if (statePort.isPresent()) {
- URI serviceUri = getServiceUri(host.name(), statePort.get());
- try {
- waitForServiceGenerationConverged(serviceUri, wantedGeneration, timeoutBudget);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- }));
- }
-
- public void waitForConfigConverged(Application application, TimeoutBudget timeoutBudget) throws IOException {
- ModelConfig config = application.getConfig(ModelConfig.class, "");
- waitForConfigConverged(config, application.getApplicationGeneration(), timeoutBudget);
- }
-
private Optional<Integer> getStatePort(ModelConfig.Hosts.Services service) { return service.ports().stream()
.filter(port -> port.tags().contains("state"))
.map(ModelConfig.Hosts.Services.Ports::number)
.findFirst();
}
- private URI getServiceUri(String host, int port) {
- return URI.create("http://" + host + ":" + port);
- }
-
- private void waitForServiceGenerationConverged(URI serviceUri, long wantedGeneration, TimeoutBudget timeoutBudget) throws InterruptedException {
- long generation = -1;
- do {
- try {
- generation = getServiceGeneration(serviceUri);
- if (generation >= wantedGeneration)
- return;
- } catch (Exception e) {
- // Try again
- }
- Thread.sleep(100);
- } while (timeoutBudget.hasTimeLeft());
- StringBuilder message = new StringBuilder("Timed out waiting for service to use config generation ").
- append(wantedGeneration).
- append(" (checking ").
- append(serviceUri).append(configPath).
- append("), ");
- if (generation == -1) {
- message.append("could not connect.");
- } else {
- message.append("generation was ").append(generation).append(".");
- }
- throw new ConfigNotConvergedException(message.toString());
- }
-
- public long generationFromContainerState(JsonNode state) {
+ private long generationFromContainerState(JsonNode state) {
return state.get("config").get("generation").asLong();
}
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 b51eede04bb..c60c4e1f64f 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
@@ -16,7 +16,6 @@ import com.yahoo.vespa.config.server.http.ContentHandler;
import com.yahoo.vespa.config.server.http.ContentRequest;
import com.yahoo.vespa.config.server.http.HttpConfigResponse;
import com.yahoo.vespa.config.server.tenant.Tenant;
-import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.HttpHandler;
@@ -26,7 +25,6 @@ import com.yahoo.vespa.config.server.http.NotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
-import java.time.Clock;
import java.time.Duration;
import java.util.concurrent.Executor;
@@ -88,14 +86,6 @@ public class ApplicationHandler extends HttpHandler {
return new ContentHandler().get(contentRequest);
}
- // TODO: Remove this once the config convergence logic is moved to client and is live for all clusters.
- if (isConvergeRequest(request)) {
- try {
- applicationRepository.waitForConfigConverged(tenant, applicationId, new TimeoutBudget(Clock.systemUTC(), durationFromRequestTimeout(request)));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
if (isServiceConvergeListRequest(request)) {
return applicationRepository.listConfigConvergence(tenant, applicationId, request.getUri());
}
@@ -168,18 +158,12 @@ public class ApplicationHandler extends HttpHandler {
"http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/content/*",
"http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/log",
"http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/restart",
- "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/converge",
"http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/serviceconverge",
"http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/serviceconverge/*",
"http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*",
"http://*/application/v2/tenant/*/application/*");
}
- private static boolean isConvergeRequest(HttpRequest request) {
- return getBindingMatch(request).groupCount() == 7 &&
- request.getUri().getPath().endsWith("/converge");
- }
-
private static boolean isServiceConvergeListRequest(HttpRequest request) {
return getBindingMatch(request).groupCount() == 7 &&
request.getUri().getPath().endsWith("/serviceconverge");
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java
index eefa4b6176d..21d0ec970ce 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java
@@ -19,7 +19,6 @@ import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.ConfigPayload;
import com.yahoo.vespa.config.buildergen.ConfigDefinition;
import com.yahoo.vespa.config.server.ServerCache;
-import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
import org.junit.Before;
import org.junit.Rule;
@@ -31,8 +30,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
-import java.time.Clock;
-import java.time.Duration;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
@@ -76,12 +73,6 @@ public class ApplicationConvergenceCheckerTest {
@Test
public void converge() throws IOException, SAXException {
ApplicationConvergenceChecker checker = new ApplicationConvergenceChecker((client, serviceUri) -> () -> string2json("{\"config\":{\"generation\":3}}"));
- checker.waitForConfigConverged(application, new TimeoutBudget(Clock.systemUTC(), Duration.ofSeconds(1)));
- }
-
- @Test
- public void convergeV2() throws IOException, SAXException {
- ApplicationConvergenceChecker checker = new ApplicationConvergenceChecker((client, serviceUri) -> () -> string2json("{\"config\":{\"generation\":3}}"));
final HttpResponse httpResponse = checker.listConfigConvergence(application, URI.create("http://foo:234/serviceconvergence"));
assertThat(httpResponse.getStatus(), is(200));
assertJsonResponseEquals(httpResponse, "{\"services\":[" +
@@ -107,13 +98,6 @@ public class ApplicationConvergenceCheckerTest {
"\"url\":\"http://foo:234/serviceconvergence\"}");
}
- // When config server constantly redeploys applications we might end up with a higher version than expected, which is OK
- @Test
- public void convergeGenerationIsLargerThanExpected() throws IOException, SAXException {
- ApplicationConvergenceChecker checker = new ApplicationConvergenceChecker((client, serviceUri) -> () -> string2json("{\"config\":{\"generation\":4}}"));
- checker.waitForConfigConverged(application, new TimeoutBudget(Clock.systemUTC(), Duration.ofSeconds(1)));
- }
-
private JsonNode string2json(String data) {
try {
return mapper.readTree(data);
@@ -122,34 +106,6 @@ public class ApplicationConvergenceCheckerTest {
}
}
- @Test
- public void convergeFailure() throws IOException {
- ApplicationConvergenceChecker checker = new ApplicationConvergenceChecker((client, serviceUri) -> () -> string2json("{\"config\":{\"generation\":2}}"));
- try {
- checker.waitForConfigConverged(application, new TimeoutBudget(Clock.systemUTC(), Duration.ofSeconds(1)));
- fail("Converge should fail due to config generation not being updated");
- } catch (ConfigNotConvergedException e) {
- assertThat(e.getMessage(), is("Timed out waiting for service to use config generation 3 (checking http://localhost:1337/state/v1/config), generation was 2."));
- }
- final HttpResponse nodeHttpResponse = checker.nodeConvergenceCheck(application, "localhost:1337", URI.create("http://foo:234/serviceconvergence"));
- assertThat(nodeHttpResponse.getStatus(), is(200));
- assertJsonResponseEquals(nodeHttpResponse, "{" +
- "\"converged\":false," +
- "\"debug\":{\"wantedGeneration\":3,\"currentGeneration\":2,\"host\":\"localhost:1337\" }," +
- "\"url\":\"http://foo:234/serviceconvergence\"}");
- }
-
- @Test
- public void stateApiFailure() throws IOException {
- ApplicationConvergenceChecker checker = new ApplicationConvergenceChecker((client, serviceUri) -> () -> string2json("{\"config\":{}}"));
- try {
- checker.waitForConfigConverged(application, new TimeoutBudget(Clock.systemUTC(), Duration.ofSeconds(1)));
- fail("Converge should fail due to config generation not being updated");
- } catch (ConfigNotConvergedException e) {
- assertThat(e.getMessage(), is("Timed out waiting for service to use config generation 3 (checking http://localhost:1337/state/v1/config), could not connect."));
- }
- }
-
private static class MockModel implements Model {
private final int statePort;
public MockModel(int statePort) {
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 4e730728ae3..d7fd292c07e 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
@@ -201,9 +201,7 @@ public class ApplicationHandlerTest {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId);
- assertFalse(stateApiFactory.createdApi);
converge(application, Zone.defaultZone());
- assertTrue(stateApiFactory.createdApi);
}
@Test
@@ -351,8 +349,8 @@ public class ApplicationHandlerTest {
}
private void converge(ApplicationId application, Zone zone) throws IOException {
- String restartUrl = toUrlPath(application, zone, true) + "/converge";
- HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(restartUrl, com.yahoo.jdisc.http.HttpRequest.Method.GET));
+ String convergeUrl = toUrlPath(application, zone, true) + "/serviceconverge";
+ HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(convergeUrl, com.yahoo.jdisc.http.HttpRequest.Method.GET));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "");
}