diff options
Diffstat (limited to 'controller-api')
4 files changed, 48 insertions, 9 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeFilter.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeFilter.java index 796ce5da449..65c8e8390c8 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeFilter.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeFilter.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.controller.api.integration.configserver; import com.google.common.collect.ImmutableSet; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostName; import java.util.Objects; @@ -22,15 +23,20 @@ public class NodeFilter { private final Set<HostName> hostnames; private final Set<HostName> parentHostnames; private final Set<ApplicationId> applications; + private final Set<ClusterSpec.Id> clusterIds; + private final Set<Node.ClusterType> clusterTypes; private NodeFilter(boolean includeDeprovisioned, Set<Node.State> states, Set<HostName> hostnames, - Set<HostName> parentHostnames, Set<ApplicationId> applications) { + Set<HostName> parentHostnames, Set<ApplicationId> applications, + Set<ClusterSpec.Id> clusterIds, Set<Node.ClusterType> clusterTypes) { this.includeDeprovisioned = includeDeprovisioned; // Uses Guava Set to preserve insertion order this.states = ImmutableSet.copyOf(Objects.requireNonNull(states)); this.hostnames = ImmutableSet.copyOf(Objects.requireNonNull(hostnames)); this.parentHostnames = ImmutableSet.copyOf(Objects.requireNonNull(parentHostnames)); this.applications = ImmutableSet.copyOf(Objects.requireNonNull(applications)); + this.clusterIds = ImmutableSet.copyOf(Objects.requireNonNull(clusterIds)); + this.clusterTypes = ImmutableSet.copyOf(Objects.requireNonNull(clusterTypes)); if (!includeDeprovisioned && states.contains(Node.State.deprovisioned)) { throw new IllegalArgumentException("Must include deprovisioned nodes when matching deprovisioned state"); } @@ -56,8 +62,16 @@ public class NodeFilter { return applications; } + public Set<ClusterSpec.Id> clusterIds() { + return clusterIds; + } + + public Set<Node.ClusterType> clusterTypes() { + return clusterTypes; + } + public NodeFilter includeDeprovisioned(boolean includeDeprovisioned) { - return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications); + return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications, clusterIds, clusterTypes); } public NodeFilter states(Node.State... states) { @@ -65,7 +79,7 @@ public class NodeFilter { } public NodeFilter states(Set<Node.State> states) { - return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications); + return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications, clusterIds, clusterTypes); } public NodeFilter hostnames(HostName... hostnames) { @@ -73,7 +87,7 @@ public class NodeFilter { } public NodeFilter hostnames(Set<HostName> hostnames) { - return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications); + return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications, clusterIds, clusterTypes); } public NodeFilter parentHostnames(HostName... parentHostnames) { @@ -81,7 +95,7 @@ public class NodeFilter { } public NodeFilter parentHostnames(Set<HostName> parentHostnames) { - return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications); + return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications, clusterIds, clusterTypes); } public NodeFilter applications(ApplicationId... applications) { @@ -89,12 +103,28 @@ public class NodeFilter { } public NodeFilter applications(Set<ApplicationId> applications) { - return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications); + return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications, clusterIds, clusterTypes); + } + + public NodeFilter clusterIds(ClusterSpec.Id... clusterIds) { + return clusterIds(ImmutableSet.copyOf(clusterIds)); + } + + public NodeFilter clusterIds(Set<ClusterSpec.Id> clusterIds) { + return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications, clusterIds, clusterTypes); + } + + public NodeFilter clusterTypes(Node.ClusterType... clusterTypes) { + return clusterTypes(ImmutableSet.copyOf(clusterTypes)); + } + + public NodeFilter clusterTypes(Set<Node.ClusterType> clusterTypes) { + return new NodeFilter(includeDeprovisioned, states, hostnames, parentHostnames, applications, clusterIds, clusterTypes); } /** A filter which matches all nodes, except deprovisioned ones */ public static NodeFilter all() { - return new NodeFilter(false, Set.of(), Set.of(), Set.of(), Set.of()); + return new NodeFilter(false, Set.of(), Set.of(), Set.of(), Set.of(), Set.of(), Set.of()); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java index 4c5a67626ea..485bf627c87 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.controller.api.integration.configserver; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.zone.ZoneId; @@ -11,6 +12,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.noderepository.Applicat import java.util.List; import java.util.Map; +import java.util.Optional; /** * Node repository interface intended for use by the controller. @@ -67,6 +69,9 @@ public interface NodeRepository { /** Retire given node */ void retire(ZoneId zone, String hostname, boolean wantToRetire, boolean wantToDeprovision); + /** Drop all documents on content nodes in the given zone, application and cluster */ + void dropDocuments(ZoneId zoneId, ApplicationId applicationId, Optional<ClusterSpec.Id> clusterId); + /** Update reports for given node. A key with null value clears that report */ void updateReports(ZoneId zone, String hostname, Map<String, String> reports); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java index fef29a99a47..ac895022130 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java @@ -173,6 +173,10 @@ enum PathGroup { Matcher.application, "/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/{environment}/region/{region}/node/{node}/service-dump"), + dropDocuments(Matcher.tenant, + Matcher.application, + "/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/{environment}/region/{region}/drop-documents"), + /** Paths used for development deployments. */ developmentDeployment(Matcher.tenant, Matcher.application, diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java index bb53ae61525..9a28226c921 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java @@ -87,7 +87,7 @@ enum Policy { /** Read access to application information and settings. */ applicationRead(Privilege.grant(Action.read) - .on(PathGroup.application, PathGroup.applicationInfo, PathGroup.reindexing, PathGroup.serviceDump) + .on(PathGroup.application, PathGroup.applicationInfo, PathGroup.reindexing, PathGroup.serviceDump, PathGroup.dropDocuments) .in(SystemName.all())), /** Update access to application information and settings. */ @@ -102,7 +102,7 @@ enum Policy { /** Full access to application information and settings. */ applicationOperations(Privilege.grant(Action.write()) - .on(PathGroup.applicationInfo, PathGroup.productionRestart, PathGroup.reindexing, PathGroup.serviceDump) + .on(PathGroup.applicationInfo, PathGroup.productionRestart, PathGroup.reindexing, PathGroup.serviceDump, PathGroup.dropDocuments) .in(SystemName.all())), /** Access to create and delete developer and deploy keys under a tenant. */ |