From 406295ad6bfcd050017a4b4b90c2854b9f84e48d Mon Sep 17 00:00:00 2001 From: Ola Aunrønning Date: Tue, 7 Jan 2020 14:26:24 +0100 Subject: Deprovision tenant host affected by cloud event --- .../hosted/controller/api/integration/aws/CloudEvent.java | 6 +++--- .../api/integration/aws/MockAwsEventFetcher.java | 15 +++++++++++++-- .../api/integration/configserver/NodeRepository.java | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'controller-api') 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 notAfter; public String awsRegionName; - public Set affectedHostnames; + public Set affectedInstances; public CloudEvent(String instanceEventId, String code, String description, Date notAfter, Date notBefore, Date notBeforeDeadline, - String awsRegionName, Set affectedHostnames) { + String awsRegionName, Set 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> mockedEvents = new HashMap<>(); + @Override public List 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/NodeRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java index 94616fd27b2..d8b6b1be5ce 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(), -- cgit v1.2.3 From 623eb417c98ee2595faa877777a97d9ca99191d0 Mon Sep 17 00:00:00 2001 From: Ola Aunrønning Date: Wed, 8 Jan 2020 13:53:28 +0100 Subject: Add wantToDeprovision and wantToRetire fields to Node --- .../api/integration/configserver/Node.java | 30 ++++++++++++++++++++-- .../integration/configserver/NodeRepository.java | 4 ++- 2 files changed, 31 insertions(+), 3 deletions(-) (limited to 'controller-api') 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 parentHostname, State state, NodeType type, NodeResources resources, Optional 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 d8b6b1be5ce..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 @@ -105,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) { -- cgit v1.2.3