diff options
author | Ola Aunrønning <olaa@verizonmedia.com> | 2020-01-09 09:55:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 09:55:00 +0100 |
commit | 461569468279dbe9012f263e26a1098b325fbe25 (patch) | |
tree | 2299808aa8e49aa4cea6246c5c925e7fd739f301 /controller-api | |
parent | 99c1d19f37cedd20901f06bf304ef3f69418eb69 (diff) | |
parent | 922b993d409c74543953dcff4b91297906b6fb05 (diff) |
Merge pull request #11683 from vespa-engine/olaa/retire-nodes-with-event
Deprovision tenant hosts affected by cloud event
Diffstat (limited to 'controller-api')
4 files changed, 49 insertions, 8 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/CloudEvent.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/CloudEvent.java index a7c8a680b73..defcda28a0f 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/CloudEvent.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/CloudEvent.java @@ -14,10 +14,10 @@ public final class CloudEvent { public final Optional<Date> notAfter; public String awsRegionName; - public Set<String> affectedHostnames; + public Set<String> affectedInstances; public CloudEvent(String instanceEventId, String code, String description, Date notAfter, Date notBefore, Date notBeforeDeadline, - String awsRegionName, Set<String> affectedHostnames) { + String awsRegionName, Set<String> affectedInstances) { this.instanceEventId = instanceEventId; this.code = code; this.description = description; @@ -26,6 +26,6 @@ public final class CloudEvent { this.notAfter = Optional.ofNullable(notAfter); this.awsRegionName = awsRegionName; - this.affectedHostnames = affectedHostnames; + this.affectedInstances = affectedInstances; } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockAwsEventFetcher.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockAwsEventFetcher.java index 79b332c093a..baf248fc31c 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockAwsEventFetcher.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockAwsEventFetcher.java @@ -2,18 +2,29 @@ package com.yahoo.vespa.hosted.controller.api.integration.aws; import com.yahoo.vespa.hosted.controller.api.integration.organization.Issue; +import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; import java.util.Optional; public class MockAwsEventFetcher implements AwsEventFetcher { + + private Map<String, List<CloudEvent>> mockedEvents = new HashMap<>(); + @Override public List<CloudEvent> getEvents(String awsRegionName) { - return List.of(); + return mockedEvents.getOrDefault(awsRegionName, new ArrayList<>()); } @Override public Issue createIssue(CloudEvent event) { - return new Issue("summary", "description", "VESPA", Optional.empty()); + return new Issue("summary", event.affectedInstances.toString(), "VESPA", Optional.empty()).with(User.from(event.awsRegionName)); + } + + public void addEvent(String awsRegionName, CloudEvent cloudEvent) { + mockedEvents.computeIfAbsent(awsRegionName, i -> new ArrayList<>()).add(cloudEvent); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java index 43fea2b76fd..8bb5775566a 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java @@ -37,11 +37,13 @@ public class Node { private final String flavor; private final String clusterId; private final ClusterType clusterType; + private final boolean wantToRetire; + private final boolean wantToDeprovision; public Node(HostName hostname, Optional<HostName> parentHostname, State state, NodeType type, NodeResources resources, Optional<ApplicationId> owner, Version currentVersion, Version wantedVersion, Version currentOsVersion, Version wantedOsVersion, ServiceState serviceState, long restartGeneration, long wantedRestartGeneration, long rebootGeneration, long wantedRebootGeneration, - int cost, String flavor, String clusterId, ClusterType clusterType) { + int cost, String flavor, String clusterId, ClusterType clusterType, boolean wantToRetire, boolean wantToDeprovision) { this.hostname = hostname; this.parentHostname = parentHostname; this.state = state; @@ -61,6 +63,8 @@ public class Node { this.flavor = flavor; this.clusterId = clusterId; this.clusterType = clusterType; + this.wantToRetire = wantToRetire; + this.wantToDeprovision = wantToDeprovision; } public HostName hostname() { @@ -137,6 +141,14 @@ public class Node { return clusterType; } + public boolean wantToRetire() { + return wantToRetire; + } + + public boolean wantToDeprovision() { + return wantToDeprovision; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -198,6 +210,8 @@ public class Node { private String flavor; private String clusterId; private ClusterType clusterType; + private boolean wantToRetire; + private boolean wantToDeprovision; public Builder() { } @@ -221,6 +235,8 @@ public class Node { this.flavor = node.flavor; this.clusterId = node.clusterId; this.clusterType = node.clusterType; + this.wantToRetire = node.wantToRetire; + this.wantToDeprovision = node.wantToDeprovision; } public Builder hostname(HostName hostname) { @@ -318,10 +334,20 @@ public class Node { return this; } + public Builder wantToRetire(boolean wantToRetire) { + this.wantToRetire = wantToRetire; + return this; + } + + public Builder wantToDeprovision(boolean wantToDeprovision) { + this.wantToDeprovision = wantToDeprovision; + return this; + } + public Node build() { return new Node(hostname, parentHostname, state, type, resources, owner, currentVersion, wantedVersion, currentOsVersion, wantedOsVersion, serviceState, restartGeneration, wantedRestartGeneration, rebootGeneration, wantedRebootGeneration, - cost, flavor, clusterId, clusterType); + cost, flavor, clusterId, clusterType, wantToRetire, wantToDeprovision); } } } 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 94616fd27b2..dd99bef5ee2 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 @@ -73,6 +73,8 @@ public interface NodeRepository { /** Cancels firmware checks on all hosts in the given zone. */ void cancelFirmwareCheck(ZoneId zone); + void retireAndDeprovision(ZoneId zoneId, String hostName); + private static Node toNode(NodeRepositoryNode node) { var application = Optional.ofNullable(node.getOwner()) .map(owner -> ApplicationId.from(owner.getTenant(), owner.getApplication(), @@ -103,7 +105,9 @@ public interface NodeRepository { toInt(node.getCost()), node.getFlavor(), clusterIdOf(node.getMembership()), - clusterTypeOf(node.getMembership())); + clusterTypeOf(node.getMembership()), + node.getWantToRetire(), + node.getWantToDeprovision()); } private static String clusterIdOf(NodeMembership nodeMembership) { |