summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-05-06 13:45:23 +0200
committerGitHub <noreply@github.com>2022-05-06 13:45:23 +0200
commite5b6198b1928184be21ea7f5d1d08b95c5647e3f (patch)
tree890bb52fc94328ad2e1bdb0ee797e659c87cf0bd
parent3779f063d0647063309275a39778c3ffcf94839d (diff)
parent776dc24d57f0d9f49412eeb33e4c912c7fe561c9 (diff)
Merge pull request #22478 from vespa-engine/freva/gcp-artifact-retention
Prepare for adding GCP ArtifactExpirer
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java6
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/Artifact.java (renamed from controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerImage.java)49
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/ArtifactRegistry.java20
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/package-info.java (renamed from controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/package-info.java)2
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerRegistry.java20
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ArtifactExpirer.java87
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContainerImageExpirer.java71
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRegistryMock.java39
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ContainerRegistryMock.java39
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArtifactExpirerTest.java (renamed from controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContainerImageExpirerTest.java)22
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json6
13 files changed, 188 insertions, 183 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java
index be32b74591b..52f687e5708 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java
@@ -1,9 +1,11 @@
// 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;
+import com.yahoo.config.provision.CloudName;
import com.yahoo.config.provision.HostName;
import com.yahoo.vespa.hosted.controller.api.identifiers.ControllerVersion;
import com.yahoo.vespa.hosted.controller.api.integration.archive.ArchiveService;
+import com.yahoo.vespa.hosted.controller.api.integration.artifact.ArtifactRegistry;
import com.yahoo.vespa.hosted.controller.api.integration.athenz.AccessControlService;
import com.yahoo.vespa.hosted.controller.api.integration.aws.CloudEventFetcher;
import com.yahoo.vespa.hosted.controller.api.integration.aws.ResourceTagger;
@@ -14,7 +16,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.billing.PlanRegistry;
import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificateProvider;
import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificateValidator;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer;
-import com.yahoo.vespa.hosted.controller.api.integration.container.ContainerRegistry;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationStore;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepository;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud;
@@ -36,6 +37,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.vcmr.ChangeRequestClien
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry;
import java.time.Clock;
+import java.util.Optional;
/**
* This provides access to all service dependencies of the controller. Implementations of this are responsible for
@@ -99,7 +101,7 @@ public interface ServiceRegistry {
BillingDatabaseClient billingDatabase();
- ContainerRegistry containerRegistry();
+ Optional<? extends ArtifactRegistry> artifactRegistry(CloudName cloudName);
TenantSecretService tenantSecretService();
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerImage.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/Artifact.java
index 9652eeef530..7ca372f6cd0 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerImage.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/Artifact.java
@@ -1,33 +1,32 @@
// 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.container;
+package com.yahoo.vespa.hosted.controller.api.integration.artifact;
import com.yahoo.component.Version;
import java.time.Instant;
import java.util.Objects;
-import java.util.Optional;
/**
- * A container image.
+ * A registry artifact (e.g. container image or RPM)
*
* @author mpolden
*/
-public class ContainerImage {
+public class Artifact {
private final String id;
private final String registry;
private final String repository;
+ private final String tag;
private final Instant createdAt;
private final Version version;
- private final Optional<Architecture> architecture;
- public ContainerImage(String id, String registry, String repository, Instant createdAt, Version version, Optional<Architecture> architecture) {
+ public Artifact(String id, String registry, String repository, String tag, Instant createdAt, Version version) {
this.id = Objects.requireNonNull(id);
this.registry = Objects.requireNonNull(registry);
this.repository = Objects.requireNonNull(repository);
+ this.tag = Objects.requireNonNull(tag);
this.createdAt = Objects.requireNonNull(createdAt);
this.version = Objects.requireNonNull(version);
- this.architecture = Objects.requireNonNull(architecture);
}
/** Unique identifier of this */
@@ -35,16 +34,21 @@ public class ContainerImage {
return id;
}
- /** The registry holding this image */
+ /** The registry holding this artifact */
public String registry() {
return registry;
}
- /** Repository of this image */
+ /** Repository of this artifact */
public String repository() {
return repository;
}
+ /** Tag of this artifact */
+ public String tag() {
+ return tag;
+ }
+
/** The time this was created */
public Instant createdAt() {
return createdAt;
@@ -55,43 +59,26 @@ public class ContainerImage {
return version;
}
- /** The architecture of this, if any */
- public Optional<Architecture> architecture() {
- return architecture;
- }
-
- /** The tag of this image */
- public String tag() {
- return version().toFullString() + architecture.map(arch -> "-" + arch.name()).orElse("");
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- ContainerImage that = (ContainerImage) o;
+ Artifact that = (Artifact) o;
return id.equals(that.id) &&
registry.equals(that.registry) &&
repository.equals(that.repository) &&
+ tag.equals(that.tag) &&
createdAt.equals(that.createdAt) &&
- version.equals(that.version) &&
- architecture.equals(that.architecture);
+ version.equals(that.version);
}
@Override
public int hashCode() {
- return Objects.hash(id, registry, repository, createdAt, version, architecture);
+ return Objects.hash(id, registry, repository, tag, createdAt, version);
}
@Override
public String toString() {
- return "container image " + repository + " [registry=" + registry + ",version=" + version.toFullString() +
- ",createdAt=" + createdAt + ",architecture=" + architecture.map(Enum::name).orElse("<none>") + "]";
+ return "artifact " + registry + "/" + repository + " [version=" + version.toFullString() + ",createdAt=" + createdAt + ",tag=" + tag + "]";
}
-
- public enum Architecture {
- amd64,
- arm64,
- }
-
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/ArtifactRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/ArtifactRegistry.java
new file mode 100644
index 00000000000..6ab8409ad11
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/ArtifactRegistry.java
@@ -0,0 +1,20 @@
+// 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.artifact;
+
+
+import java.util.List;
+
+/**
+ * A registry of artifacts (e.g. container image or RPM).
+ *
+ * @author mpolden
+ */
+public interface ArtifactRegistry {
+
+ /** Delete all given artifacts */
+ void deleteAll(List<Artifact> artifacts);
+
+ /** Returns a list of all artifacts in this system */
+ List<Artifact> list();
+
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/package-info.java
index ca1f6afc5db..8e12be06583 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/package-info.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/artifact/package-info.java
@@ -3,6 +3,6 @@
* @author mpolden
*/
@ExportPackage
-package com.yahoo.vespa.hosted.controller.api.integration.container;
+package com.yahoo.vespa.hosted.controller.api.integration.artifact;
import com.yahoo.osgi.annotation.ExportPackage;
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerRegistry.java
deleted file mode 100644
index 78757ad995a..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerRegistry.java
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.container;
-
-
-import java.util.List;
-
-/**
- * A registry of container images.
- *
- * @author mpolden
- */
-public interface ContainerRegistry {
-
- /** Delete all given images */
- void deleteAll(List<ContainerImage> images);
-
- /** Returns a list of all container images in this system */
- List<ContainerImage> list();
-
-}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ArtifactExpirer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ArtifactExpirer.java
new file mode 100644
index 00000000000..81fbb85e3d7
--- /dev/null
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ArtifactExpirer.java
@@ -0,0 +1,87 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.controller.maintenance;
+
+import com.yahoo.component.Version;
+import com.yahoo.config.provision.CloudName;
+import com.yahoo.config.provision.SystemName;
+import com.yahoo.vespa.hosted.controller.Controller;
+import com.yahoo.vespa.hosted.controller.api.integration.artifact.Artifact;
+import com.yahoo.vespa.hosted.controller.api.integration.artifact.ArtifactRegistry;
+import com.yahoo.vespa.hosted.controller.versions.VersionStatus;
+import com.yahoo.vespa.hosted.controller.versions.VespaVersion;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+
+/**
+ * Periodically expire unused artifacts, e.g. container images and RPMs.
+ *
+ * @author mpolden
+ */
+public class ArtifactExpirer extends ControllerMaintainer {
+
+ private static final Logger log = Logger.getLogger(ArtifactExpirer.class.getName());
+
+ private static final Duration MIN_AGE = Duration.ofDays(14);
+
+ public ArtifactExpirer(Controller controller, Duration interval) {
+ super(controller, interval, null, expiringSystems());
+ }
+
+ @Override
+ protected double maintain() {
+ VersionStatus versionStatus = controller().readVersionStatus();
+ return controller().clouds().stream()
+ .flatMapToDouble(cloud ->
+ controller().serviceRegistry().artifactRegistry(cloud).stream()
+ .mapToDouble(artifactRegistry -> maintain(versionStatus, cloud, artifactRegistry)))
+ .average()
+ .orElse(1);
+ }
+
+ private double maintain(VersionStatus versionStatus, CloudName cloudName, ArtifactRegistry artifactRegistry) {
+ try {
+ Instant now = controller().clock().instant();
+ List<Artifact> artifactsToExpire = artifactRegistry.list().stream()
+ .filter(artifact -> isExpired(artifact, now, versionStatus))
+ .collect(Collectors.toList());
+ if (!artifactsToExpire.isEmpty()) {
+ log.log(Level.INFO, "Expiring " + artifactsToExpire.size() + " artifacts: " + artifactsToExpire);
+ artifactRegistry.deleteAll(artifactsToExpire);
+ }
+ return 1;
+ } catch (RuntimeException e) {
+ log.log(Level.WARNING, "Failed to expire artifacts in " + cloudName + ". Will retry in " + interval(), e);
+ return 0;
+ }
+ }
+
+ /** Returns whether given artifact is expired */
+ private boolean isExpired(Artifact artifact, Instant now, VersionStatus versionStatus) {
+ List<VespaVersion> versions = versionStatus.versions();
+ if (versions.isEmpty()) return false;
+
+ if (versionStatus.isActive(artifact.version())) return false;
+ if (artifact.createdAt().isAfter(now.minus(MIN_AGE))) return false;
+
+ Version maxVersion = versions.stream().map(VespaVersion::versionNumber).max(Comparator.naturalOrder()).get();
+ if (artifact.version().isAfter(maxVersion)) return false; // A future version
+
+ return true;
+ }
+
+ /** Returns systems where artifacts can be expired */
+ private static Set<SystemName> expiringSystems() {
+ // Run only in public and main. Public systems have distinct container registries, while main and CD have
+ // shared registries.
+ return EnumSet.of(SystemName.Public, SystemName.PublicCd, SystemName.main);
+ }
+
+}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContainerImageExpirer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContainerImageExpirer.java
deleted file mode 100644
index c87dd262fa3..00000000000
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContainerImageExpirer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.maintenance;
-
-import com.yahoo.component.Version;
-import com.yahoo.config.provision.SystemName;
-import com.yahoo.vespa.hosted.controller.Controller;
-import com.yahoo.vespa.hosted.controller.api.integration.container.ContainerImage;
-import com.yahoo.vespa.hosted.controller.versions.VersionStatus;
-import com.yahoo.vespa.hosted.controller.versions.VespaVersion;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.util.Comparator;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-/**
- * Periodically expire unused container images.
- *
- * @author mpolden
- */
-public class ContainerImageExpirer extends ControllerMaintainer {
-
- private static final Logger log = Logger.getLogger(ContainerImageExpirer.class.getName());
-
- private static final Duration MIN_AGE = Duration.ofDays(14);
-
- public ContainerImageExpirer(Controller controller, Duration interval) {
- super(controller, interval, null, expiringSystems());
- }
-
- @Override
- protected double maintain() {
- Instant now = controller().clock().instant();
- VersionStatus versionStatus = controller().readVersionStatus();
- List<ContainerImage> imagesToExpire = controller().serviceRegistry().containerRegistry().list().stream()
- .filter(image -> isExpired(image, now, versionStatus))
- .collect(Collectors.toList());
- if (!imagesToExpire.isEmpty()) {
- log.log(Level.INFO, "Expiring " + imagesToExpire.size() + " container images: " + imagesToExpire);
- controller().serviceRegistry().containerRegistry().deleteAll(imagesToExpire);
- }
- return 1.0;
- }
-
- /** Returns whether given image is expired */
- private boolean isExpired(ContainerImage image, Instant now, VersionStatus versionStatus) {
- List<VespaVersion> versions = versionStatus.versions();
- if (versions.isEmpty()) return false;
-
- if (versionStatus.isActive(image.version())) return false;
- if (image.createdAt().isAfter(now.minus(MIN_AGE))) return false;
-
- Version maxVersion = versions.stream().map(VespaVersion::versionNumber).max(Comparator.naturalOrder()).get();
- if (image.version().isAfter(maxVersion)) return false; // A future version
-
- return true;
- }
-
- /** Returns systems where images can be expired */
- private static Set<SystemName> expiringSystems() {
- // Run only in public and main. Public systems have distinct container registries, while main and CD have
- // shared registries.
- return EnumSet.of(SystemName.Public, SystemName.PublicCd, SystemName.main);
- }
-
-}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
index e4aa80b7b93..193d171e334 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
@@ -63,7 +63,7 @@ public class ControllerMaintenance extends AbstractComponent {
maintainers.add(new ResourceTagMaintainer(controller, intervals.resourceTagMaintainer, controller.serviceRegistry().resourceTagger()));
maintainers.add(new SystemRoutingPolicyMaintainer(controller, intervals.systemRoutingPolicyMaintainer));
maintainers.add(new ApplicationMetaDataGarbageCollector(controller, intervals.applicationMetaDataGarbageCollector));
- maintainers.add(new ContainerImageExpirer(controller, intervals.containerImageExpirer));
+ maintainers.add(new ArtifactExpirer(controller, intervals.containerImageExpirer));
maintainers.add(new HostInfoUpdater(controller, intervals.hostInfoUpdater));
maintainers.add(new ReindexingTriggerer(controller, intervals.reindexingTriggerer));
maintainers.add(new EndpointCertificateMaintainer(controller, intervals.endpointCertificateMaintainer));
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRegistryMock.java
new file mode 100644
index 00000000000..ef0445e06c6
--- /dev/null
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRegistryMock.java
@@ -0,0 +1,39 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.controller.integration;
+
+import com.yahoo.vespa.hosted.controller.api.integration.artifact.Artifact;
+import com.yahoo.vespa.hosted.controller.api.integration.artifact.ArtifactRegistry;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author mpolden
+ */
+public class ArtifactRegistryMock implements ArtifactRegistry {
+
+ private static final Comparator<Artifact> comparator = Comparator.comparing(Artifact::registry)
+ .thenComparing(Artifact::repository)
+ .thenComparing(Artifact::version);
+
+ private final Map<String, Artifact> images = new HashMap<>();
+
+ public ArtifactRegistryMock add(Artifact image) {
+ images.put(image.id(), image);
+ return this;
+ }
+
+ @Override
+ public void deleteAll(List<Artifact> artifacts) {
+ artifacts.forEach(image -> this.images.remove(image.id()));
+ }
+
+ @Override
+ public List<Artifact> list() {
+ return images.values().stream().sorted(comparator).collect(Collectors.toUnmodifiableList());
+ }
+
+}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ContainerRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ContainerRegistryMock.java
deleted file mode 100644
index 4791017548d..00000000000
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ContainerRegistryMock.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.integration;
-
-import com.yahoo.vespa.hosted.controller.api.integration.container.ContainerImage;
-import com.yahoo.vespa.hosted.controller.api.integration.container.ContainerRegistry;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * @author mpolden
- */
-public class ContainerRegistryMock implements ContainerRegistry {
-
- private static final Comparator<ContainerImage> comparator = Comparator.comparing(ContainerImage::registry)
- .thenComparing(ContainerImage::repository)
- .thenComparing(ContainerImage::version);
-
- private final Map<String, ContainerImage> images = new HashMap<>();
-
- public ContainerRegistryMock add(ContainerImage image) {
- images.put(image.id(), image);
- return this;
- }
-
- @Override
- public void deleteAll(List<ContainerImage> images) {
- images.forEach(image -> this.images.remove(image.id()));
- }
-
- @Override
- public List<ContainerImage> list() {
- return images.values().stream().sorted(comparator).collect(Collectors.toUnmodifiableList());
- }
-
-}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
index 7b42dbff488..a91d81bb0c5 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
@@ -5,6 +5,7 @@ import com.yahoo.component.annotation.Inject;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.component.AbstractComponent;
import com.yahoo.component.Version;
+import com.yahoo.config.provision.CloudName;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.SystemName;
import com.yahoo.test.ManualClock;
@@ -50,6 +51,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.user.RoleMaintainerMock
import com.yahoo.vespa.hosted.controller.api.integration.vcmr.MockChangeRequestClient;
import java.time.Instant;
+import java.util.Optional;
/**
* A mock implementation of a {@link ServiceRegistry} for testing purposes.
@@ -82,7 +84,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
private final MockResourceTagger mockResourceTagger = new MockResourceTagger();
private final RoleService roleService = new MockRoleService();
private final BillingController billingController = new MockBillingController(clock);
- private final ContainerRegistryMock containerRegistry = new ContainerRegistryMock();
+ private final ArtifactRegistryMock containerRegistry = new ArtifactRegistryMock();
private final NoopTenantSecretService tenantSecretService = new NoopTenantSecretService();
private final ArchiveService archiveService = new MockArchiveService();
private final MockChangeRequestClient changeRequestClient = new MockChangeRequestClient();
@@ -236,8 +238,8 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
}
@Override
- public ContainerRegistryMock containerRegistry() {
- return containerRegistry;
+ public Optional<ArtifactRegistryMock> artifactRegistry(CloudName cloudName) {
+ return Optional.of(containerRegistry);
}
@Override
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContainerImageExpirerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArtifactExpirerTest.java
index baebf7239ee..7703266c9ba 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContainerImageExpirerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArtifactExpirerTest.java
@@ -2,35 +2,33 @@
package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.component.Version;
-import com.yahoo.vespa.hosted.controller.api.integration.container.ContainerImage;
-import com.yahoo.vespa.hosted.controller.api.integration.container.ContainerImage.Architecture;
+import com.yahoo.config.provision.CloudName;
+import com.yahoo.vespa.hosted.controller.api.integration.artifact.Artifact;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
-import com.yahoo.vespa.hosted.controller.integration.ContainerRegistryMock;
+import com.yahoo.vespa.hosted.controller.integration.ArtifactRegistryMock;
import org.junit.Test;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
-import java.util.Optional;
import static org.junit.Assert.assertEquals;
/**
* @author mpolden
*/
-public class ContainerImageExpirerTest {
+public class ArtifactExpirerTest {
@Test
public void maintain() {
DeploymentTester tester = new DeploymentTester();
- ContainerImageExpirer expirer = new ContainerImageExpirer(tester.controller(), Duration.ofDays(1));
- ContainerRegistryMock registry = tester.controllerTester().serviceRegistry().containerRegistry();
+ ArtifactExpirer expirer = new ArtifactExpirer(tester.controller(), Duration.ofDays(1));
+ ArtifactRegistryMock registry = tester.controllerTester().serviceRegistry().artifactRegistry(CloudName.defaultName()).orElseThrow();
Instant instant = tester.clock().instant();
- ContainerImage image0 = new ContainerImage("image0", "registry.example.com", "vespa/vespa", instant, Version.fromString("7.1"), Optional.empty());
- ContainerImage image1 = new ContainerImage("image1", "registry.example.com", "vespa/vespa", instant, Version.fromString("7.2"), Optional.of(Architecture.amd64));
- ContainerImage image2 = new ContainerImage("image2", "registry.example.com", "vespa/vespa", instant, Version.fromString("7.4"), Optional.of(Architecture.amd64));
-
+ Artifact image0 = new Artifact("image0", "registry.example.com", "vespa/vespa", "7.1", instant, Version.fromString("7.1"));
+ Artifact image1 = new Artifact("image1", "registry.example.com", "vespa/vespa", "7.2-amd64", instant, Version.fromString("7.2"));
+ Artifact image2 = new Artifact("image2", "registry.example.com", "vespa/vespa", "7.4-amd64", instant, Version.fromString("7.4"));
registry.add(image0)
.add(image1)
.add(image2);
@@ -53,7 +51,7 @@ public class ContainerImageExpirerTest {
assertEquals(List.of(image1, image2), registry.list());
// A new version becomes active. The active and future version are kept
- ContainerImage image3 = new ContainerImage("image3", "registry.example.com", "vespa/vespa", tester.clock().instant(), Version.fromString("7.3"), Optional.of(Architecture.amd64));
+ Artifact image3 = new Artifact("image3", "registry.example.com", "vespa/vespa", "7.3-arm64", tester.clock().instant(), Version.fromString("7.3"));
registry.add(image3);
tester.controllerTester().upgradeSystem(image3.version());
expirer.maintain();
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
index 79e11fa1140..8b2e5578ae0 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
@@ -13,6 +13,9 @@
"name": "ArchiveUriUpdater"
},
{
+ "name": "ArtifactExpirer"
+ },
+ {
"name": "BillingDatabaseMaintainer"
},
{
@@ -28,9 +31,6 @@
"name": "ContactInformationMaintainer"
},
{
- "name": "ContainerImageExpirer"
- },
- {
"name": "CostReportMaintainer"
},
{