summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2019-08-14 11:38:43 +0200
committerHarald Musum <musum@verizonmedia.com>2019-08-14 11:38:43 +0200
commit9910428d50c0c10a726eb493841827b743fed366 (patch)
tree924cc3888091f265e239a1e3c2a42a18bfb9dd23
parent16fbeca959c5952fe0644a675b36f84fc59bfcbe (diff)
Add config setting for throwing if active session cannot be loaded
THe feature flag that controlled this earlier has been removed, there might still be exceptional cases where one might need to do this to get a config server to start. Zookeeper server will not start if an exception is thrown, so it is not possible to fix anything if the state somehow has become bad
-rw-r--r--configdefinitions/src/vespa/configserver.def1
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java34
2 files changed, 22 insertions, 13 deletions
diff --git a/configdefinitions/src/vespa/configserver.def b/configdefinitions/src/vespa/configserver.def
index af1ced533ad..e7e626f3d22 100644
--- a/configdefinitions/src/vespa/configserver.def
+++ b/configdefinitions/src/vespa/configserver.def
@@ -63,5 +63,6 @@ sleepTimeWhenRedeployingFails long default=30
# Features (to be overridden in configserver-config.xml if needed)
buildMinimalSetOfConfigModels bool default=true
throwIfBootstrappingTenantRepoFails bool default=true
+throwIfActiveSessionCannotBeLoaded bool default=true
canReturnEmptySentinelConfig bool default=false
serverNodeType enum {config, controller} default=config
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java
index 5d930472111..936b9bdefda 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
+import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -43,6 +44,7 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> {
private static final Logger log = Logger.getLogger(RemoteSessionRepo.class.getName());
+ private final GlobalComponentRegistry componentRegistry;
private final Curator curator;
private final Path sessionsPath;
private final RemoteSessionFactory remoteSessionFactory;
@@ -54,22 +56,23 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> {
private final TenantApplications applicationRepo;
private final Executor zkWatcherExecutor;
- public RemoteSessionRepo(GlobalComponentRegistry registry,
+ public RemoteSessionRepo(GlobalComponentRegistry componentRegistry,
RemoteSessionFactory remoteSessionFactory,
ReloadHandler reloadHandler,
TenantName tenantName,
TenantApplications applicationRepo) {
- this.curator = registry.getCurator();
+ this.componentRegistry = componentRegistry;
+ this.curator = componentRegistry.getCurator();
this.sessionsPath = TenantRepository.getSessionsPath(tenantName);
this.applicationRepo = applicationRepo;
this.remoteSessionFactory = remoteSessionFactory;
this.reloadHandler = reloadHandler;
this.tenantName = tenantName;
- this.metrics = registry.getMetrics().getOrCreateMetricUpdater(Metrics.createDimensions(tenantName));
- StripedExecutor<TenantName> zkWatcherExecutor = registry.getZkWatcherExecutor();
+ this.metrics = componentRegistry.getMetrics().getOrCreateMetricUpdater(Metrics.createDimensions(tenantName));
+ StripedExecutor<TenantName> zkWatcherExecutor = componentRegistry.getZkWatcherExecutor();
this.zkWatcherExecutor = command -> zkWatcherExecutor.execute(tenantName, command);
initializeSessions();
- this.directoryCache = curator.createDirectoryCache(sessionsPath.getAbsolute(), false, false, registry.getZkCacheExecutor());
+ this.directoryCache = curator.createDirectoryCache(sessionsPath.getAbsolute(), false, false, componentRegistry.getZkCacheExecutor());
this.directoryCache.addListener(this::childEvent);
this.directoryCache.start();
}
@@ -136,14 +139,19 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> {
*/
private void sessionAdded(long sessionId) {
log.log(LogLevel.DEBUG, () -> "Adding session to RemoteSessionRepo: " + sessionId);
- RemoteSession session = remoteSessionFactory.createSession(sessionId);
- Path sessionPath = sessionsPath.append(String.valueOf(sessionId));
- Curator.FileCache fileCache = curator.createFileCache(sessionPath.append(ConfigCurator.SESSIONSTATE_ZK_SUBPATH).getAbsolute(), false);
- fileCache.addListener(this::nodeChanged);
- loadSessionIfActive(session);
- sessionStateWatchers.put(sessionId, new RemoteSessionStateWatcher(fileCache, reloadHandler, session, metrics, zkWatcherExecutor));
- addSession(session);
- metrics.incAddedSessions();
+ try {
+ RemoteSession session = remoteSessionFactory.createSession(sessionId);
+ Path sessionPath = sessionsPath.append(String.valueOf(sessionId));
+ Curator.FileCache fileCache = curator.createFileCache(sessionPath.append(ConfigCurator.SESSIONSTATE_ZK_SUBPATH).getAbsolute(), false);
+ fileCache.addListener(this::nodeChanged);
+ loadSessionIfActive(session);
+ sessionStateWatchers.put(sessionId, new RemoteSessionStateWatcher(fileCache, reloadHandler, session, metrics, zkWatcherExecutor));
+ addSession(session);
+ metrics.incAddedSessions();
+ } catch (Exception e) {
+ if (componentRegistry.getConfigserverConfig().throwIfActiveSessionCannotBeLoaded()) throw e;
+ log.log(Level.WARNING, "Failed loading session " + sessionId + ": No config for this session can be served", e);
+ }
}
private void sessionRemoved(long sessionId) {