diff options
author | Harald Musum <musum@oath.com> | 2018-07-06 14:32:35 +0200 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-07-06 14:45:00 +0200 |
commit | 3b77e99bc84e56b4e57a2fcabad689cba1f595e0 (patch) | |
tree | b6b493eb53df21a8049cb980c6b0d79e58333fc6 /configserver | |
parent | 09e7e1e7b010b0117b9d8736fcc309b6bcde0d8e (diff) |
Make sleep time configurable (avoid spending a long time in unit tests)
Diffstat (limited to 'configserver')
3 files changed, 7 insertions, 4 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 e8cfcf75de3..935c9faec9b 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 @@ -666,13 +666,13 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } } - boolean redeployAllApplications(Duration maxDuration) throws InterruptedException { + boolean redeployAllApplications(Duration maxDuration, Duration sleepBetweenRetries) throws InterruptedException { Instant end = Instant.now().plus(maxDuration); Set<ApplicationId> applicationsNotRedeployed = listApplications(); do { applicationsNotRedeployed = redeployApplications(applicationsNotRedeployed); if ( ! applicationsNotRedeployed.isEmpty()) { - Thread.sleep(Duration.ofSeconds(30).toMillis()); + Thread.sleep(sleepBetweenRetries.toMillis()); } } while ( ! applicationsNotRedeployed.isEmpty() && Instant.now().isBefore(end)); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java index 6e6f60b29dd..3584e614071 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java @@ -41,6 +41,7 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable private final StateMonitor stateMonitor; private final VipStatus vipStatus; private final Duration maxDurationOfRedeployment; + private final Duration sleepTimeWhenRedeployingFails; private final RedeployingApplicationsFails exitIfRedeployingApplicationsFails; // The tenants object is injected so that all initial requests handlers are @@ -63,6 +64,7 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable this.serverThread = new Thread(this, "configserver main"); this.vipStatus = vipStatus; this.maxDurationOfRedeployment = Duration.ofSeconds(applicationRepository.configserverConfig().maxDurationOfBootstrap()); + this.sleepTimeWhenRedeployingFails = Duration.ofSeconds(applicationRepository.configserverConfig().sleepTimeWhenRedeployingFails()); this.exitIfRedeployingApplicationsFails = exitIfRedeployingApplicationsFails; initializing(); // Initially take server out of rotation if (mainThread == MainThread.START) @@ -88,7 +90,7 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable log.log(LogLevel.INFO, "Configserver upgrading from " + versionState.storedVersion() + " to " + versionState.currentVersion() + ". Redeploying all applications"); try { - if ( ! applicationRepository.redeployAllApplications(maxDurationOfRedeployment)) { + if ( ! applicationRepository.redeployAllApplications(maxDurationOfRedeployment, sleepTimeWhenRedeployingFails)) { redeployingApplicationsFailed(); return; // Status will not be set to 'up' since we return here } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java index dbb02e367a7..74d8c508b26 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java @@ -125,7 +125,8 @@ public class ConfigServerBootstrapTest { .configDefinitionsDir(temporaryFolder.newFolder("configdefinitions").getAbsolutePath()) .hostedVespa(true) .multitenant(true) - .maxDurationOfBootstrap(1) /* seconds */); + .maxDurationOfBootstrap(1) /* seconds */ + .sleepTimeWhenRedeployingFails(0)); /* seconds */ } public static class MockRpc extends com.yahoo.vespa.config.server.rpc.MockRpc { |