aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-10-02 13:57:24 +0200
committerHarald Musum <musum@yahooinc.com>2023-10-02 13:57:24 +0200
commit5eadb1c4b3bfc01517e08c3c8336cf5647c8165e (patch)
tree561dcf570d41ed1aae8e75da00f06fe89301488c /configserver
parent5706d89036798a37025409a70dfdded8c6545a9a (diff)
Read application id through SessionData
Read from old or new path based on feature flag
Diffstat (limited to 'configserver')
-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/session/SessionRepository.java6
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionSerializer.java44
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java2
4 files changed, 41 insertions, 15 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 e675e00b642..1aeaebafd84 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
@@ -501,7 +501,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
Session session = getLocalSession(tenant, sessionId);
Deployment deployment = Deployment.prepared(session, this, hostProvisioner, tenant, logger, timeoutBudget.timeout(), clock, false, force);
deployment.activate();
- return session.getApplicationId();
+ return sessionRepository(tenant).read(session).applicationId();
}
public Transaction deactivateCurrentActivateNew(Optional<Session> active, Session prepared, boolean force) {
@@ -557,6 +557,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
}
+ private static SessionRepository sessionRepository(Tenant tenant) { return tenant.getSessionRepository(); }
+
// ---------------- Application operations ----------------------------------------------------------------
/**
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..c53d1a13200 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
@@ -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..08b66c28a12 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
@@ -10,11 +10,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 +26,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 +59,30 @@ 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 dato for session " + zooKeeperClient.sessionId() +
+ ": " + Exceptions.toMessageString(e));
+ readSessionDataFromLegacyPaths(zooKeeperClient);
+ }
+
+ 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/SessionZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java
index 378cd9bdb8c..eaddce3de91 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
@@ -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