From 8e628d458757d5ed5a77ee791a29b39e4effded3 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Tue, 3 Nov 2020 11:23:59 +0100 Subject: Expire stale container images --- .../api/integration/ServiceRegistry.java | 4 ++ .../api/integration/container/ContainerImage.java | 78 ++++++++++++++++++++++ .../integration/container/ContainerRegistry.java | 20 ++++++ 3 files changed, 102 insertions(+) create mode 100644 controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerImage.java create mode 100644 controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerRegistry.java (limited to 'controller-api') 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 7b4d82a9f53..8f2d2161f92 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 @@ -7,6 +7,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.aws.ResourceTagger; import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingController; import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificateProvider; 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; @@ -81,4 +82,7 @@ public interface ServiceRegistry { BillingController billingController(); HostRepairClient hostRepairClient(); + + ContainerRegistry containerRegistry(); + } 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/container/ContainerImage.java new file mode 100644 index 00000000000..904c64a2197 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerImage.java @@ -0,0 +1,78 @@ +// Copyright Verizon Media. 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 com.yahoo.component.Version; + +import java.time.Instant; +import java.util.Objects; + +/** + * A container image. + * + * @author mpolden + */ +public class ContainerImage { + + private final String id; + private final String registry; + private final String repository; + private final Instant createdAt; + private final Version version; + + public ContainerImage(String id, String registry, String repository, Instant createdAt, Version version) { + this.id = Objects.requireNonNull(id); + this.registry = Objects.requireNonNull(registry); + this.repository = Objects.requireNonNull(repository); + this.createdAt = Objects.requireNonNull(createdAt); + this.version = Objects.requireNonNull(version); + } + + /** Unique identifier of this */ + public String id() { + return id; + } + + /** The registry holding this image */ + public String registry() { + return registry; + } + + /** Repository of this image */ + public String repository() { + return repository; + } + + /** The time this was created */ + public Instant createdAt() { + return createdAt; + } + + /** The version of this */ + public Version version() { + return version; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ContainerImage that = (ContainerImage) o; + return id.equals(that.id) && + registry.equals(that.registry) && + repository.equals(that.repository) && + createdAt.equals(that.createdAt) && + version.equals(that.version); + } + + @Override + public int hashCode() { + return Objects.hash(id, registry, repository, createdAt, version); + } + + @Override + public String toString() { + return "container image " + repository + " [registry=" + registry + ",version=" + version.toFullString() + + ",createdAt=" + createdAt + "]"; + } + +} 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 new file mode 100644 index 00000000000..f11c474415b --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/container/ContainerRegistry.java @@ -0,0 +1,20 @@ +// Copyright Verizon Media. 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 images); + + /** Returns a list of all container images in this system */ + List list(); + +} -- cgit v1.2.3