diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-09-16 14:06:23 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-09-16 14:06:23 +0200 |
commit | c12dfa2fef99ad6bf76cf7560002b5f821bcab23 (patch) | |
tree | 022d23ae2a70b31d605c46c1aac0181f05072725 | |
parent | 42e573b6b444d392d1351886295728bc65c93c71 (diff) |
Wait with deployments until bootstrapping has finished
4 files changed, 19 insertions, 14 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Deployer.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Deployer.java index 2e53d4384a4..9cfe3fdd1cc 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/Deployer.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Deployer.java @@ -65,4 +65,7 @@ public interface Deployer { /** Returns the time the current local active session was created, or empty if there is no local active session */ Optional<Instant> lastDeployTime(ApplicationId application); + /** Whether the deployer is bootstrapping, some users of the deployer will want to hold off with deployments in that case. */ + default boolean bootstrapping() { return false; }; + } 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 824d6701233..59b9c549319 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 @@ -87,6 +87,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -112,6 +113,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye private static final Logger log = Logger.getLogger(ApplicationRepository.class.getName()); + private final AtomicBoolean bootstrapping = new AtomicBoolean(true); + private final TenantRepository tenantRepository; private final Optional<Provisioner> hostProvisioner; private final Optional<InfraDeployer> infraDeployer; @@ -268,6 +271,15 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye // ---------------- Deploying ---------------------------------------------------------------- + @Override + public boolean bootstrapping() { + return bootstrapping.get(); + } + + public void bootstrappingDone() { + bootstrapping.set(false); + } + public PrepareResult prepare(Tenant tenant, long sessionId, PrepareParams prepareParams, Instant now) { validateThatLocalSessionIsNotActive(tenant, sessionId); LocalSession session = getLocalSession(tenant, sessionId); @@ -367,6 +379,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye SessionRepository sessionRepository = tenant.getSessionRepository(); LocalSession newSession = sessionRepository.createSessionFromExisting(activeSession, logger, true, timeoutBudget); sessionRepository.addLocalSession(newSession); + sessionRepository.createRemoteSession(newSession.getSessionId()); return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, timeout, clock, false /* don't validate as this is already deployed */, bootstrap)); @@ -815,6 +828,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye timeoutBudget, activeSessionId); tenant.getSessionRepository().addLocalSession(session); + tenant.getSessionRepository().createRemoteSession(session.getSessionId()); return session.getSessionId(); } 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 749561d5fdb..609ff4473c6 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 @@ -10,11 +10,8 @@ import com.yahoo.config.provision.Deployment; import com.yahoo.config.provision.TransientException; import com.yahoo.container.handler.VipStatus; import com.yahoo.container.jdisc.state.StateMonitor; -import com.yahoo.vespa.config.server.maintenance.FileDistributionMaintainer; import com.yahoo.vespa.config.server.rpc.RpcServer; import com.yahoo.vespa.config.server.version.VersionState; -import com.yahoo.vespa.curator.Curator; -import com.yahoo.vespa.flags.FlagSource; import com.yahoo.yolean.Exceptions; import java.time.Duration; @@ -166,6 +163,7 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable return; // Status will not be set to 'up' since we return here } } + applicationRepository.bootstrappingDone(); startRpcServer(); up(); } 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 3cb0f935888..e3128dfc8e9 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 @@ -7,7 +7,6 @@ import com.yahoo.jdisc.Metric; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; -import java.time.Clock; import java.time.Duration; import java.time.Instant; import java.util.LinkedHashSet; @@ -27,15 +26,11 @@ import java.util.stream.Collectors; public class PeriodicApplicationMaintainer extends ApplicationMaintainer { private final Duration minTimeBetweenRedeployments; - private final Clock clock; - private final Instant start; PeriodicApplicationMaintainer(Deployer deployer, Metric metric, NodeRepository nodeRepository, Duration interval, Duration minTimeBetweenRedeployments) { super(deployer, metric, nodeRepository, interval); this.minTimeBetweenRedeployments = minTimeBetweenRedeployments; - this.clock = nodeRepository.clock(); - this.start = clock.instant(); } @Override @@ -51,7 +46,7 @@ public class PeriodicApplicationMaintainer extends ApplicationMaintainer { // Returns the applications that need to be redeployed by this config server at this point in time. @Override protected Set<ApplicationId> applicationsNeedingMaintenance() { - if (waitInitially()) return Set.of(); + if (deployer().bootstrapping()) return Set.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#deployWithLock @@ -75,11 +70,6 @@ public class PeriodicApplicationMaintainer extends ApplicationMaintainer { return true; } - // TODO: Do not start deploying until some time has gone (ideally only until bootstrap of config server is finished) - private boolean waitInitially() { - return clock.instant().isBefore(start.plus(minTimeBetweenRedeployments)); - } - protected List<Node> nodesNeedingMaintenance() { return nodeRepository().getNodes(Node.State.active); } |