summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-03-09 08:20:44 +0100
committerHarald Musum <musum@verizonmedia.com>2021-03-09 08:20:44 +0100
commit576d68d04f7ae2b548d5391bfd54a46226647f69 (patch)
tree4759277918398dcfedeeca503c14b2722744e231
parent103c77a2cdd86edcf69ba68d41806d3e99c204b9 (diff)
Redeploy applications when bootstrapping in random order
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java12
2 files changed, 9 insertions, 7 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 c044a545b6f..9f101d44269 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
@@ -664,10 +664,10 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
}
- public Set<ApplicationId> listApplications() {
+ public List<ApplicationId> listApplications() {
return tenantRepository.getAllTenants().stream()
.flatMap(tenant -> tenant.getApplicationRepo().activeApplications().stream())
- .collect(Collectors.toSet());
+ .collect(Collectors.toList());
}
private boolean isFileLastModifiedBefore(File fileReference, Instant instant) {
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 3275dc42477..be26e880440 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
@@ -17,10 +17,11 @@ import com.yahoo.yolean.Exceptions;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -203,7 +204,8 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable
private boolean redeployAllApplications() throws InterruptedException {
Instant end = Instant.now().plus(maxDurationOfRedeployment);
- Set<ApplicationId> applicationsNotRedeployed = applicationRepository.listApplications();
+ List<ApplicationId> applicationsNotRedeployed = applicationRepository.listApplications();
+ Collections.shuffle(applicationsNotRedeployed);
long failCount = 0;
do {
applicationsNotRedeployed = redeployApplications(applicationsNotRedeployed);
@@ -225,7 +227,7 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable
}
// Returns the set of applications that failed to redeploy
- private Set<ApplicationId> redeployApplications(Set<ApplicationId> applicationIds) throws InterruptedException {
+ private List<ApplicationId> redeployApplications(List<ApplicationId> applicationIds) throws InterruptedException {
ExecutorService executor = Executors.newFixedThreadPool(configserverConfig.numParallelTenantLoaders(),
new DaemonThreadFactory("redeploy apps"));
// Keep track of deployment per application
@@ -235,12 +237,12 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable
executor.submit(() -> applicationRepository.deployFromLocalActive(appId, true /* bootstrap */)
.ifPresent(Deployment::activate))));
- Set<ApplicationId> failedDeployments =
+ List<ApplicationId> failedDeployments =
deployments.entrySet().stream()
.map(entry -> checkDeployment(entry.getKey(), entry.getValue()))
.filter(Optional::isPresent)
.map(Optional::get)
- .collect(Collectors.toSet());
+ .collect(Collectors.toList());
executor.shutdown();
executor.awaitTermination(365, TimeUnit.DAYS); // Timeout should never happen