summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2017-09-04 09:50:15 +0200
committerHarald Musum <musum@oath.com>2017-09-04 09:50:15 +0200
commite19d9f4ef86f8abb135a224429e85bdc9814a815 (patch)
tree3d7f545b28970beba7821d39a79b16c87c25481c /configserver
parent01fab1f2a7302d470c2a25e21c95dd5a5b766e1c (diff)
Only create hosted-vespa tenant on hosted installations
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java19
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListTenantsTest.java2
2 files changed, 11 insertions, 10 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java
index 70be29fa80d..3ad920bbff2 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server.tenant;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;
+import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.concurrent.ThreadFactoryFactory;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.TenantName;
@@ -20,7 +21,6 @@ import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.zookeeper.KeeperException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -56,7 +56,6 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen
public static final TenantName HOSTED_VESPA_TENANT = TenantName.from("hosted-vespa");
private static final TenantName DEFAULT_TENANT = TenantName.defaultName();
- private static final List<TenantName> SYSTEM_TENANT_NAMES = Arrays.asList(DEFAULT_TENANT, HOSTED_VESPA_TENANT);
private static final Path tenantsPath = Path.fromString("/config/v2/tenants/");
private static final Path vespaPath = Path.fromString("/vespa");
@@ -89,7 +88,7 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen
curator.framework().getConnectionStateListenable().addListener(this);
curator.create(tenantsPath);
- createSystemTenants();
+ createSystemTenants(globalComponentRegistry.getConfigserverConfig());
curator.create(vespaPath);
this.directoryCache = curator.createDirectoryCache(tenantsPath.getAbsolute(), false, false, pathChildrenExecutor);
@@ -213,12 +212,16 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen
}
/**
- * Writes the default tenant into ZooKeeper. Will not fail if the node already exists,
- * as this is OK and might happen when several config servers start at the same time and
- * try to call this method.
+ * Writes the tenants that should always be present into ZooKeeper. Will not fail if the node
+ * already exists, as this is OK and might happen when several config servers start at the
+ * same time and try to call this method.
*/
- public synchronized void createSystemTenants() {
- for (final TenantName tenantName : SYSTEM_TENANT_NAMES) {
+ private synchronized void createSystemTenants(ConfigserverConfig configserverConfig) {
+ List<TenantName> systemTenants = new ArrayList<>();
+ systemTenants.add(DEFAULT_TENANT);
+ if (configserverConfig.hostedVespa()) systemTenants.add(HOSTED_VESPA_TENANT);
+
+ for (final TenantName tenantName : systemTenants) {
try {
writeTenantPath(tenantName);
} catch (RuntimeException e) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListTenantsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListTenantsTest.java
index 78dfdd62f1c..189314577e4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListTenantsTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListTenantsTest.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.config.server.http.v2;
import com.yahoo.config.provision.TenantName;
-import com.yahoo.vespa.config.server.tenant.Tenants;
import org.junit.Test;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.jdisc.http.HttpRequest.Method;
@@ -34,7 +33,6 @@ public class ListTenantsTest extends TenantTest {
private static void assertContainsSystemTenants(final Collection<TenantName> tenantNames) {
assertTrue(tenantNames.contains(TenantName.defaultName()));
- assertTrue(tenantNames.contains(Tenants.HOSTED_VESPA_TENANT));
}
@Test