diff options
Diffstat (limited to 'configserver/src/main/java/com/yahoo/vespa/config/server/session')
11 files changed, 48 insertions, 23 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java index 6eb2743834a..322486c7b21 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.config.application.api.ApplicationPackage; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java index f00e37e0ee8..19f227f8dc8 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.component.Version; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java index aa6d33fbda8..da5169cf493 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.config.provision.TenantName; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java index f354b5238b2..37ebfa12e7e 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.component.Version; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionData.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionData.java index 1d5a560fc8b..6c27eefc055 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionData.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionData.java @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.component.Version; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java index 67872865106..90087a25c59 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.cloud.config.ConfigserverConfig; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index eb07e3010c6..99d5d23a87c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.google.common.collect.HashMultiset; @@ -131,6 +131,7 @@ public class SessionRepository { private final int maxNodeSize; private final LongFlag expiryTimeFlag; private final BooleanFlag writeSessionData; + private final BooleanFlag readSessionData; public SessionRepository(TenantName tenantName, TenantApplications applicationRepo, @@ -176,6 +177,7 @@ public class SessionRepository { this.maxNodeSize = maxNodeSize; this.expiryTimeFlag = PermanentFlags.CONFIG_SERVER_SESSION_EXPIRY_TIME.bindTo(flagSource); this.writeSessionData = Flags.WRITE_CONFIG_SERVER_SESSION_DATA_AS_ONE_BLOB.bindTo(flagSource); + this.readSessionData = Flags.READ_CONFIG_SERVER_SESSION_DATA_AS_ONE_BLOB.bindTo(flagSource); loadSessions(); // Needs to be done before creating cache below this.directoryCache = curator.createDirectoryCache(sessionsPath.getAbsolute(), false, false, zkCacheExecutor); @@ -607,6 +609,10 @@ public class SessionRepository { writeSessionData); } + public SessionData read(Session session) { + return new SessionSerializer().read(session.getSessionZooKeeperClient(), readSessionData); + } + // ---------------- Common stuff ---------------------------------------------------------------- public void deleteExpiredSessions(Map<ApplicationId, Long> activeSessions) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionSerializer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionSerializer.java index 46acb8c7ef1..f71476c5770 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionSerializer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionSerializer.java @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.component.Version; @@ -10,11 +11,15 @@ import com.yahoo.config.provision.CloudAccount; import com.yahoo.config.provision.DataplaneToken; import com.yahoo.config.provision.DockerImage; import com.yahoo.vespa.flags.BooleanFlag; +import com.yahoo.yolean.Exceptions; import java.security.cert.X509Certificate; import java.time.Instant; import java.util.List; import java.util.Optional; +import java.util.logging.Logger; + +import static java.util.logging.Level.WARNING; /** * Serialization and deserialization of session data to/from ZooKeeper. @@ -22,6 +27,8 @@ import java.util.Optional; */ public class SessionSerializer { + private static final Logger log = Logger.getLogger(SessionSerializer.class.getName()); + void write(SessionZooKeeperClient zooKeeperClient, ApplicationId applicationId, Instant created, Optional<FileReference> fileReference, Optional<DockerImage> dockerImageRepository, Version vespaVersion, Optional<AthenzDomain> athenzDomain, Optional<Quota> quota, @@ -53,20 +60,29 @@ public class SessionSerializer { } SessionData read(SessionZooKeeperClient zooKeeperClient, BooleanFlag readSessionData) { - if (readSessionData.value()) - return zooKeeperClient.readSessionData(); - else - return new SessionData(zooKeeperClient.readApplicationId(), - zooKeeperClient.readApplicationPackageReference(), - zooKeeperClient.readVespaVersion(), - zooKeeperClient.readCreateTime(), - zooKeeperClient.readDockerImageRepository(), - zooKeeperClient.readAthenzDomain(), - zooKeeperClient.readQuota(), - zooKeeperClient.readTenantSecretStores(), - zooKeeperClient.readOperatorCertificates(), - zooKeeperClient.readCloudAccount(), - zooKeeperClient.readDataplaneTokens()); + if (readSessionData.value() && zooKeeperClient.sessionDataExists()) + try { + return zooKeeperClient.readSessionData(); + } catch (Exception e) { + log.log(WARNING, "Unable to read session data for session " + zooKeeperClient.sessionId() + + ": " + Exceptions.toMessageString(e)); + } + + return readSessionDataFromLegacyPaths(zooKeeperClient); + } + + private static SessionData readSessionDataFromLegacyPaths(SessionZooKeeperClient zooKeeperClient) { + return new SessionData(zooKeeperClient.readApplicationId(), + zooKeeperClient.readApplicationPackageReference(), + zooKeeperClient.readVespaVersion(), + zooKeeperClient.readCreateTime(), + zooKeeperClient.readDockerImageRepository(), + zooKeeperClient.readAthenzDomain(), + zooKeeperClient.readQuota(), + zooKeeperClient.readTenantSecretStores(), + zooKeeperClient.readOperatorCertificates(), + zooKeeperClient.readCloudAccount(), + zooKeeperClient.readDataplaneTokens()); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java index 34cebaca1fa..88d584d3e5e 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.text.Utf8; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java index 378cd9bdb8c..cbd6e956d1d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.yahoo.cloud.config.ConfigserverConfig; @@ -229,6 +229,8 @@ public class SessionZooKeeperClient { return SessionData.fromSlime(SlimeUtils.jsonToSlime(curator.getData(sessionPath.append(SESSION_DATA_PATH)).orElseThrow())); } + public boolean sessionDataExists() { return curator.exists(sessionPath.append(SESSION_DATA_PATH)); } + public Version readVespaVersion() { Optional<byte[]> data = curator.getData(versionPath()); // TODO: Empty version should not be possible any more - verify and remove diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SilentDeployLogger.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SilentDeployLogger.java index f2b1dbe23e8..4c4dc2d1891 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SilentDeployLogger.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SilentDeployLogger.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import java.util.logging.Level; |