summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2018-06-27 13:58:51 +0200
committerGitHub <noreply@github.com>2018-06-27 13:58:51 +0200
commit023089ca3180cea8fa7490d0d6f4a9083e9bc213 (patch)
treee14d60eff2dfdceb114e83d3bb742cebb519fe53
parentfe34fc0746fc5fb9a131d83595fd48ba5b1f680c (diff)
parent322cf95fcd7d7ce6bf1be0a3b131dd1f1e37ede1 (diff)
Merge pull request #6297 from vespa-engine/hmusum/run-tenants-maintainer-only-in-cd
Run TenantsMaintainer only in CD
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ConfigServerMaintenance.java10
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java19
2 files changed, 24 insertions, 5 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ConfigServerMaintenance.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ConfigServerMaintenance.java
index fd5d09a4ff2..1f8e8ff6fe8 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ConfigServerMaintenance.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ConfigServerMaintenance.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server.maintenance;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.component.AbstractComponent;
+import com.yahoo.config.provision.SystemName;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.session.FileDistributionFactory;
import com.yahoo.vespa.curator.Curator;
@@ -21,7 +22,7 @@ public class ConfigServerMaintenance extends AbstractComponent {
Curator curator,
FileDistributionFactory fileDistributionFactory) {
DefaultTimes defaults = new DefaultTimes(configserverConfig);
- tenantsMaintainer = new TenantsMaintainer(applicationRepository, curator, defaults.defaultInterval);
+ tenantsMaintainer = new TenantsMaintainer(applicationRepository, curator, defaults.tenantsMaintainerInterval);
zooKeeperDataMaintainer = new ZooKeeperDataMaintainer(applicationRepository, curator, defaults.defaultInterval);
fileDistributionMaintainer = new FileDistributionMaintainer(applicationRepository, curator, defaults.defaultInterval, configserverConfig);
}
@@ -40,9 +41,16 @@ public class ConfigServerMaintenance extends AbstractComponent {
private static class DefaultTimes {
private final Duration defaultInterval;
+ private final Duration tenantsMaintainerInterval;
DefaultTimes(ConfigserverConfig configserverConfig) {
this.defaultInterval = Duration.ofMinutes(configserverConfig.maintainerIntervalMinutes());
+ boolean isCd = configserverConfig.system().equals(SystemName.cd.name());
+ // TODO: Want job control or feature flag to control when to run this, for now use a very
+ // long interval to avoid running the maintainer except in CD
+ this.tenantsMaintainerInterval = isCd
+ ? defaultInterval
+ : Duration.ofMinutes(configserverConfig.tenantsMaintainerIntervalMinutes());
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java
index 63ee9dfe3d9..a2f52bc5321 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java
@@ -23,6 +23,7 @@ public class TenantsMaintainerTest {
MaintainerTester tester = new MaintainerTester();
TenantRepository tenantRepository = tester.tenantRepository();
ApplicationRepository applicationRepository = tester.applicationRepository();
+ File applicationPackage = new File("src/test/apps/app");
TenantName shouldBeDeleted = TenantName.from("to-be-deleted");
TenantName shouldNotBeDeleted = TenantName.from("should-not-be-deleted");
@@ -30,10 +31,8 @@ public class TenantsMaintainerTest {
tenantRepository.addTenant(shouldBeDeleted);
tenantRepository.addTenant(shouldNotBeDeleted);
tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT);
- applicationRepository.deploy(new File("src/test/apps/app"),
- new PrepareParams.Builder()
- .applicationId(ApplicationId.from(shouldNotBeDeleted, ApplicationName.from("foo"), InstanceName.defaultName()))
- .build());
+
+ applicationRepository.deploy(applicationPackage, prepareParams(shouldNotBeDeleted));
assertNotNull(tenantRepository.getTenant(shouldBeDeleted));
assertNotNull(tenantRepository.getTenant(shouldNotBeDeleted));
@@ -46,5 +45,17 @@ public class TenantsMaintainerTest {
// System tenants should not be deleted
assertNotNull(tenantRepository.getTenant(TenantName.defaultName()));
assertNotNull(tenantRepository.getTenant(TenantRepository.HOSTED_VESPA_TENANT));
+
+ // Add tenant again and deploy
+ tenantRepository.addTenant(shouldBeDeleted);
+ tester.applicationRepository().deploy(applicationPackage, prepareParams(shouldBeDeleted));
+ }
+
+ private PrepareParams prepareParams(TenantName tenantName) {
+ return new PrepareParams.Builder().applicationId(applicationId(tenantName)).build();
+ }
+
+ private ApplicationId applicationId(TenantName tenantName) {
+ return ApplicationId.from(tenantName, ApplicationName.from("foo"), InstanceName.defaultName());
}
}