summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2019-05-09 16:01:21 +0200
committerGitHub <noreply@github.com>2019-05-09 16:01:21 +0200
commitdec444d48b3f9c33d0356a30eb2d1a34a581e778 (patch)
tree32d4ca9f2364f8261d355c5b6087e55466fe1921 /configserver
parent811d1c8e4296d059216d2b99377a69592d53d710 (diff)
parente6ed2b1b027c82fb4aca7cdf48397cdbb9dd2354 (diff)
Merge pull request #9333 from vespa-engine/freva/fix-node-failer
Return deployment for infrastructure applications
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java15
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/deploy/InfraDeployerProvider.java59
-rw-r--r--configserver/src/main/resources/configserver-app/services.xml3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java4
4 files changed, 76 insertions, 5 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 55f35de2443..b4414562170 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
@@ -15,6 +15,7 @@ import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.HostFilter;
+import com.yahoo.config.provision.InfraDeployer;
import com.yahoo.config.provision.Provisioner;
import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.SystemName;
@@ -37,6 +38,7 @@ import com.yahoo.vespa.config.server.configchange.RefeedActions;
import com.yahoo.vespa.config.server.configchange.RestartActions;
import com.yahoo.vespa.config.server.deploy.DeployHandlerLogger;
import com.yahoo.vespa.config.server.deploy.Deployment;
+import com.yahoo.vespa.config.server.deploy.InfraDeployerProvider;
import com.yahoo.vespa.config.server.http.CompressedApplicationInputStream;
import com.yahoo.vespa.config.server.http.LogRetriever;
import com.yahoo.vespa.config.server.http.SimpleHttpFetcher;
@@ -93,6 +95,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
private final TenantRepository tenantRepository;
private final Optional<Provisioner> hostProvisioner;
+ private final Optional<InfraDeployer> infraDeployer;
private final ConfigConvergenceChecker convergeChecker;
private final HttpProxy httpProxy;
private final Clock clock;
@@ -105,11 +108,12 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
@Inject
public ApplicationRepository(TenantRepository tenantRepository,
HostProvisionerProvider hostProvisionerProvider,
+ InfraDeployerProvider infraDeployerProvider,
ConfigConvergenceChecker configConvergenceChecker,
- HttpProxy httpProxy,
+ HttpProxy httpProxy,
ConfigserverConfig configserverConfig,
Orchestrator orchestrator) {
- this(tenantRepository, hostProvisionerProvider.getHostProvisioner(),
+ this(tenantRepository, hostProvisionerProvider.getHostProvisioner(), infraDeployerProvider.getInfraDeployer(),
configConvergenceChecker, httpProxy, configserverConfig, orchestrator,
Clock.systemUTC(), new FileDistributionStatus());
}
@@ -128,12 +132,13 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
Orchestrator orchestrator,
Clock clock,
ConfigserverConfig configserverConfig) {
- this(tenantRepository, Optional.of(hostProvisioner), new ConfigConvergenceChecker(), new HttpProxy(new SimpleHttpFetcher()),
+ this(tenantRepository, Optional.of(hostProvisioner), Optional.empty(), new ConfigConvergenceChecker(), new HttpProxy(new SimpleHttpFetcher()),
configserverConfig, orchestrator, clock, new FileDistributionStatus());
}
private ApplicationRepository(TenantRepository tenantRepository,
Optional<Provisioner> hostProvisioner,
+ Optional<InfraDeployer> infraDeployer,
ConfigConvergenceChecker configConvergenceChecker,
HttpProxy httpProxy,
ConfigserverConfig configserverConfig,
@@ -142,6 +147,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
FileDistributionStatus fileDistributionStatus) {
this.tenantRepository = tenantRepository;
this.hostProvisioner = hostProvisioner;
+ this.infraDeployer = infraDeployer;
this.convergeChecker = configConvergenceChecker;
this.httpProxy = httpProxy;
this.clock = clock;
@@ -247,6 +253,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application,
Duration timeout,
boolean bootstrap) {
+ Optional<com.yahoo.config.provision.Deployment> infraDeployment = infraDeployer.flatMap(d -> d.getDeployment(application));
+ if (infraDeployment.isPresent()) return infraDeployment;
+
Tenant tenant = tenantRepository.getTenant(application.tenant());
if (tenant == null) return Optional.empty();
LocalSession activeSession = getActiveSession(tenant, application);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/InfraDeployerProvider.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/InfraDeployerProvider.java
new file mode 100644
index 00000000000..bc15121e190
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/InfraDeployerProvider.java
@@ -0,0 +1,59 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config.server.deploy;
+
+import com.yahoo.cloud.config.ConfigserverConfig;
+import com.yahoo.component.ComponentId;
+import com.yahoo.component.provider.ComponentRegistry;
+import com.yahoo.config.provision.InfraDeployer;
+
+import java.util.Optional;
+
+/**
+ * This class is necessary to support both having and not having an infrastructure deployer. We inject
+ * a component registry here, which then enables us to check whether or not we have an infrastructure
+ * deployer available. We only have an infrastructure deployer if we are running in hosted mode.
+ *
+ * @author freva
+ */
+public class InfraDeployerProvider {
+
+ private final Optional<InfraDeployer> infraDeployer;
+
+ public InfraDeployerProvider(ComponentRegistry<InfraDeployer> infraDeployerRegistry, ConfigserverConfig configserverConfig) {
+ if (infraDeployerRegistry.allComponents().isEmpty() || ! configserverConfig.hostedVespa()) {
+ infraDeployer = Optional.empty();
+ } else {
+ infraDeployer = Optional.of(infraDeployerRegistry.allComponents().get(0));
+ }
+ }
+
+ private InfraDeployerProvider(ComponentRegistry<InfraDeployer> componentRegistry) {
+ this(componentRegistry, new ConfigserverConfig(new ConfigserverConfig.Builder()));
+ }
+
+ /** Returns the infrastructure deployer, or empty if we are not in hosted mode */
+ public Optional<InfraDeployer> getInfraDeployer() {
+ return infraDeployer;
+ }
+
+ // for testing
+ public static InfraDeployerProvider empty() {
+ return new InfraDeployerProvider(new ComponentRegistry<>());
+ }
+
+ // for testing
+ public static InfraDeployerProvider withInfraDeployer(InfraDeployer infraDeployer) {
+ ComponentRegistry<InfraDeployer> registry = new ComponentRegistry<>();
+ registry.register(ComponentId.createAnonymousComponentId("foobar"), infraDeployer);
+ return new InfraDeployerProvider(registry, new ConfigserverConfig(new ConfigserverConfig.Builder().hostedVespa(true)));
+ }
+
+ /** Creates either an empty provider or a provider having the given infrastructure deployer */
+ public static InfraDeployerProvider from(Optional<InfraDeployer> infraDeployer) {
+ if (infraDeployer.isPresent())
+ return withInfraDeployer(infraDeployer.get());
+ else
+ return empty();
+ }
+
+}
diff --git a/configserver/src/main/resources/configserver-app/services.xml b/configserver/src/main/resources/configserver-app/services.xml
index 5aca82409a9..23864e7d3e8 100644
--- a/configserver/src/main/resources/configserver-app/services.xml
+++ b/configserver/src/main/resources/configserver-app/services.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<services version="1.0" xmlns:preprocess="properties" xmlns:deploy="vespa">
+<services version="1.0" xmlns:preprocess="properties">
<jdisc id="configserver" jetty="true" version="1.0">
<config name="container.jdisc.config.health-monitor">
<initialStatus>initializing</initialStatus>
@@ -22,6 +22,7 @@
<component id="com.yahoo.vespa.config.server.SuperModelRequestHandler" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.StaticConfigDefinitionRepo" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.provision.HostProvisionerProvider" bundle="configserver" />
+ <component id="com.yahoo.vespa.config.server.deploy.InfraDeployerProvider" bundle="configserver" />
<component id="com.yahoo.vespa.curator.Curator" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.InjectedGlobalComponentRegistry" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.tenant.TenantRepository" bundle="configserver" />
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 fa560ceae4d..a843212927b 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
@@ -17,10 +17,11 @@ 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.InfraDeployerProvider;
import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
-import com.yahoo.vespa.config.server.http.StaticResponse;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
+import com.yahoo.vespa.config.server.http.StaticResponse;
import com.yahoo.vespa.config.server.provision.HostProvisionerProvider;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.tenant.Tenant;
@@ -163,6 +164,7 @@ public class ApplicationHandlerTest {
HttpProxy mockHttpProxy = mock(HttpProxy.class);
ApplicationRepository applicationRepository = new ApplicationRepository(tenantRepository,
HostProvisionerProvider.withProvisioner(provisioner),
+ InfraDeployerProvider.empty(),
new ConfigConvergenceChecker(stateApiFactory),
mockHttpProxy,
new ConfigserverConfig(new ConfigserverConfig.Builder()),