diff options
author | jonmv <venstad@gmail.com> | 2023-08-30 15:35:34 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-08-30 15:35:34 +0200 |
commit | f151fb9eb0d8a61f27227e5bebd990a9ded3b0cc (patch) | |
tree | 6cc78ebd755d01128026b26b373842192e91a13d /node-repository/src/main/java | |
parent | 5b9fadac979ca1aacaa653409e29cea2cea876d1 (diff) |
Trigger periodic redeployment for apps with readied reindexing
Diffstat (limited to 'node-repository/src/main/java')
2 files changed, 17 insertions, 24 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java index ba71bbf0d42..14693c75436 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java @@ -13,9 +13,7 @@ import com.yahoo.vespa.hosted.provision.NodeList; import com.yahoo.vespa.hosted.provision.NodeRepository; import java.time.Duration; -import java.time.Instant; import java.util.Map; -import java.util.function.Function; import static java.util.stream.Collectors.toMap; @@ -41,34 +39,21 @@ public class PeriodicApplicationMaintainer extends ApplicationMaintainer { @Override protected boolean canDeployNow(ApplicationId application) { return deployer().deployTime(application) - // Don't deploy if a regular deploy just happened - .map(lastDeployTime -> lastDeployTime.isBefore(nodeRepository().clock().instant().minus(minTimeBetweenRedeployments))) - // We only know last deploy time for applications that were deployed on this config server, - // the rest will be deployed on another config server - .orElse(false); + .map(lastDeployTime -> lastDeployTime.isBefore(nodeRepository().clock().instant().minus(minTimeBetweenRedeployments)) + || deployer().readiedReindexingAfter(application, lastDeployTime)) + .orElse(false); } @Override protected Map<ApplicationId, String> applicationsNeedingMaintenance() { if (deployer().bootstrapping()) return Map.of(); - // Collect all deployment times before sorting as deployments may happen while we build the set, breaking - // the comparable contract. Stale times are fine as the time is rechecked in ApplicationMaintainer#deployNow - Map<ApplicationId, Instant> deploymentTimes = nodesNeedingMaintenance().stream() - .map(node -> node.allocation().get().owner()) - .distinct() - .filter(this::canDeployNow) - .collect(toMap(Function.identity(), this::deployTime)); - - return deploymentTimes.entrySet().stream() - .sorted(Map.Entry.comparingByValue()) - .map(Map.Entry::getKey) - .filter(this::shouldMaintain) - .collect(toMap(applicationId -> applicationId, applicationId -> "current deployment being too old")); - } - - private Instant deployTime(ApplicationId applicationId) { - return deployer().deployTime(applicationId).orElse(Instant.EPOCH); + return nodesNeedingMaintenance().stream() + .map(node -> node.allocation().get().owner()) + .distinct() + .filter(this::shouldMaintain) + .filter(this::canDeployNow) + .collect(toMap(applicationId -> applicationId, applicationId -> "current deployment being too old")); } private boolean shouldMaintain(ApplicationId id) { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDeployer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDeployer.java index 4b4e9121be4..0573c6a877e 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDeployer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDeployer.java @@ -50,6 +50,7 @@ public class MockDeployer implements Deployer { private boolean failActivate = false; private boolean bootstrapping = true; + private Instant readiedReindexingAt = null; /** Create a mock deployer which returns empty on every deploy request. */ @Inject @@ -91,6 +92,8 @@ public class MockDeployer implements Deployer { public void setBootstrapping(boolean bootstrapping) { this.bootstrapping = bootstrapping; } + public void setReadiedReindexingAt(Instant readiedReindexingAt) { this.readiedReindexingAt = readiedReindexingAt; } + @Override public Optional<Deployment> deployFromLocalActive(ApplicationId id, boolean bootstrap) { return deployFromLocalActive(id, Duration.ofSeconds(60)); @@ -131,6 +134,11 @@ public class MockDeployer implements Deployer { } @Override + public boolean readiedReindexingAfter(ApplicationId application, Instant instant) { + return readiedReindexingAt != null && readiedReindexingAt.isAfter(instant); + } + + @Override public boolean bootstrapping() { return bootstrapping; } |