aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@yahooinc.com>2023-09-25 11:25:26 +0200
committerValerij Fredriksen <valerijf@yahooinc.com>2023-09-26 09:41:30 +0200
commit9501a01800b6626d84b75255d678b619701c1b1f (patch)
tree6e913ad3b8245e8cfd7e478dbcfb1f8a9e43ceb5 /controller-api
parent4231e6077a18b6fdf96ac899a7301882ef50d742 (diff)
Add method to extract enclave template version
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/ArchiveService.java17
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/MockArchiveService.java6
2 files changed, 23 insertions, 0 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/ArchiveService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/ArchiveService.java
index ed965f4331e..66cf3eef954 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/ArchiveService.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/ArchiveService.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.archive;
+import com.yahoo.component.Version;
import com.yahoo.config.provision.CloudAccount;
import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.zone.ZoneId;
@@ -10,6 +11,7 @@ import java.net.URI;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Stream;
/**
* Service that manages archive storage URIs for tenant nodes.
@@ -28,4 +30,19 @@ public interface ArchiveService {
Optional<String> findEnclaveArchiveBucket(ZoneId zoneId, CloudAccount cloudAccount);
URI bucketURI(ZoneId zoneId, String bucketName);
+
+ /**
+ * @return the version of the template that was used during the last apply for the given cloud account,
+ * or {@link Version#emptyVersion} if the version tag was not present or invalid,
+ * or {@link Optional#empty()} if the we have no access to the cloud account (template probably not applied yet)
+ */
+ Optional<Version> getEnclaveTemplateVersion(CloudAccount cloudAccount);
+
+ static Stream<Version> parseVersion(String versionString) {
+ try {
+ return Stream.of(Version.fromString(versionString));
+ } catch (IllegalArgumentException e) {
+ return Stream.empty();
+ }
+ }
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/MockArchiveService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/MockArchiveService.java
index 7461d3aa47e..4e6e71ca855 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/MockArchiveService.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/MockArchiveService.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.archive;
+import com.yahoo.component.Version;
import com.yahoo.config.provision.CloudAccount;
import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.zone.ZoneId;
@@ -59,6 +60,11 @@ public class MockArchiveService implements ArchiveService {
return URI.create(String.format("s3://%s/", bucketName));
}
+ @Override
+ public Optional<Version> getEnclaveTemplateVersion(CloudAccount cloudAccount) {
+ return Optional.of(new Version(1, 2, 3));
+ }
+
public void setEnclaveArchiveBucket(ZoneId zoneId, CloudAccount cloudAccount, String bucketName) {
removeEnclaveArchiveBucket(zoneId, cloudAccount);