summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2020-11-23 17:17:40 +0100
committerGitHub <noreply@github.com>2020-11-23 17:17:40 +0100
commitbb001b8e430b0d85ec8a463d92940c843f0facea (patch)
tree9bdb0851491d885d05acc36b46f3b14ae294d796
parent3e47c04e90374152274efd6c06df4155c7fe6ec6 (diff)
parent6cfcb42e3a3b8945c0f34567f1c495248ae7a135 (diff)
Merge pull request #15432 from vespa-engine/bratseth/pass-more-cluster-info
Pass more cluster info
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java29
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ClusterData.java11
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java1
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java31
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java11
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java9
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-clusters.json34
7 files changed, 121 insertions, 5 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java
index fd339e3bb43..98b7ffd1d47 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java
@@ -4,6 +4,8 @@ package com.yahoo.vespa.hosted.controller.api.integration.configserver;
import com.yahoo.config.provision.ClusterResources;
import com.yahoo.config.provision.ClusterSpec;
+import java.time.Instant;
+import java.util.List;
import java.util.Optional;
/**
@@ -17,19 +19,25 @@ public class Cluster {
private final ClusterResources current;
private final Optional<ClusterResources> target;
private final Optional<ClusterResources> suggested;
+ private final List<ScalingEvent> scalingEvents;
+ private final String autoscalingStatus;
public Cluster(ClusterSpec.Id id,
ClusterResources min,
ClusterResources max,
ClusterResources current,
Optional<ClusterResources> target,
- Optional<ClusterResources> suggested) {
+ Optional<ClusterResources> suggested,
+ List<ScalingEvent> scalingEvents,
+ String autoscalingStatus) {
this.id = id;
this.min = min;
this.max = max;
this.current = current;
this.target = target;
this.suggested = suggested;
+ this.scalingEvents = scalingEvents;
+ this.autoscalingStatus = autoscalingStatus;
}
public ClusterSpec.Id id() { return id; }
@@ -38,10 +46,29 @@ public class Cluster {
public ClusterResources current() { return current; }
public Optional<ClusterResources> target() { return target; }
public Optional<ClusterResources> suggested() { return suggested; }
+ public List<ScalingEvent> scalingEvents() { return scalingEvents; }
+ public String autoscalingStatus() { return autoscalingStatus; }
@Override
public String toString() {
return "cluster '" + id + "'";
}
+ public static class ScalingEvent {
+
+ private final ClusterResources from, to;
+ private final Instant at;
+
+ public ScalingEvent(ClusterResources from, ClusterResources to, Instant at) {
+ this.from = from;
+ this.to = to;
+ this.at = at;
+ }
+
+ public ClusterResources from() { return from; }
+ public ClusterResources to() { return to; }
+ public Instant at() { return at; }
+
+ }
+
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ClusterData.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ClusterData.java
index 298928a881d..99a72fbc827 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ClusterData.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ClusterData.java
@@ -7,7 +7,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Cluster;
+import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
* @author bratseth
@@ -26,6 +28,10 @@ public class ClusterData {
public ClusterResourcesData suggested;
@JsonProperty("target")
public ClusterResourcesData target;
+ @JsonProperty("scalingEvents")
+ public List<ScalingEventData> scalingEvents;
+ @JsonProperty("autoscalingStatus")
+ public String autoscalingStatus;
public Cluster toCluster(String id) {
return new Cluster(ClusterSpec.Id.from(id),
@@ -33,7 +39,10 @@ public class ClusterData {
max.toClusterResources(),
current.toClusterResources(),
target == null ? Optional.empty() : Optional.of(target.toClusterResources()),
- suggested == null ? Optional.empty() : Optional.of(suggested.toClusterResources()));
+ suggested == null ? Optional.empty() : Optional.of(suggested.toClusterResources()),
+ scalingEvents == null ? List.of()
+ : scalingEvents.stream().map(data -> data.toScalingEvent()).collect(Collectors.toList()),
+ autoscalingStatus);
}
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java
index 97e7f2e897a..393814478dd 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeHistory.java
@@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class NodeHistory {
+
@JsonProperty("at")
public Long at;
@JsonProperty("agent")
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java
new file mode 100644
index 00000000000..b33a7436522
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java
@@ -0,0 +1,31 @@
+// 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.noderepository;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.yahoo.vespa.hosted.controller.api.integration.configserver.Cluster;
+
+import java.time.Instant;
+
+/**
+ * @author bratseth
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ScalingEventData {
+
+ @JsonProperty("from")
+ public ClusterResourcesData from;
+
+ @JsonProperty("to")
+ public ClusterResourcesData to;
+
+ @JsonProperty("at")
+ public Long at;
+
+ public Cluster.ScalingEvent toScalingEvent() {
+ return new Cluster.ScalingEvent(from.toClusterResources(), to.toClusterResources(), Instant.ofEpochMilli(at));
+ }
+
+}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index fc0b8eb9fee..740a70fc6d1 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -701,6 +701,8 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
toSlime(cluster.current(), clusterObject.setObject("current"));
cluster.target().ifPresent(target -> toSlime(target, clusterObject.setObject("target")));
cluster.suggested().ifPresent(suggested -> toSlime(suggested, clusterObject.setObject("suggested")));
+ scalingEventsToSlime(cluster.scalingEvents(), clusterObject.setArray("scalingEvents"));
+ clusterObject.setString("autoscalingStatus", cluster.autoscalingStatus());
}
return new SlimeJsonResponse(slime);
}
@@ -1914,6 +1916,15 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
object.setDouble("cost", Math.round(resources.nodes() * resources.nodeResources().cost() * 100.0 / 3.0) / 100.0);
}
+ private void scalingEventsToSlime(List<Cluster.ScalingEvent> scalingEvents, Cursor scalingEventsArray) {
+ for (Cluster.ScalingEvent scalingEvent : scalingEvents) {
+ Cursor scalingEventObject = scalingEventsArray.addObject();
+ toSlime(scalingEvent.from(), scalingEventObject.setObject("from"));
+ toSlime(scalingEvent.to(), scalingEventObject.setObject("to"));
+ scalingEventObject.setLong("at", scalingEvent.at().toEpochMilli());
+ }
+ }
+
private void toSlime(NodeResources resources, Cursor object) {
object.setDouble("vcpu", resources.vcpu());
object.setDouble("memoryGb", resources.memoryGb());
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
index 8acce352d5a..27b739160fc 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
@@ -108,12 +108,17 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
/** Assigns a reserved tenant node to the given deployment, with initial versions. */
public void provision(ZoneId zone, ApplicationId application, ClusterSpec.Id clusterId) {
+ var current = new ClusterResources(2, 1, new NodeResources(2, 8, 50, 1, slow, remote));
Cluster cluster = new Cluster(clusterId,
new ClusterResources(2, 1, new NodeResources(1, 4, 20, 1, slow, remote)),
new ClusterResources(2, 1, new NodeResources(4, 16, 90, 1, slow, remote)),
- new ClusterResources(2, 1, new NodeResources(2, 8, 50, 1, slow, remote)),
+ current,
Optional.of(new ClusterResources(2, 1, new NodeResources(3, 8, 50, 1, slow, remote))),
- Optional.empty());
+ Optional.empty(),
+ List.of(new Cluster.ScalingEvent(new ClusterResources(0, 0, NodeResources.unspecified()),
+ current,
+ Instant.ofEpochMilli(1234))),
+ "the autoscaling status");
nodeRepository.putApplication(zone,
new com.yahoo.vespa.hosted.controller.api.integration.configserver.Application(application,
List.of(cluster)));
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-clusters.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-clusters.json
index 65fa2a4bf70..817cee7732a 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-clusters.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-clusters.json
@@ -52,7 +52,39 @@
"storageType": "remote"
},
"cost": "(ignore)"
- }
+ },
+ "scalingEvents": [
+ {
+ "from": {
+ "nodes": 0,
+ "groups": 0,
+ "nodeResources": {
+ "vcpu": 0.0,
+ "memoryGb": 0.0,
+ "diskGb": 0.0,
+ "bandwidthGbps": 0.0,
+ "diskSpeed": "fast",
+ "storageType": "any"
+ },
+ "cost": "(ignore)"
+ },
+ "to": {
+ "nodes": 2,
+ "groups": 1,
+ "nodeResources": {
+ "vcpu": 2.0,
+ "memoryGb": 8.0,
+ "diskGb": 50.0,
+ "bandwidthGbps": 1.0,
+ "diskSpeed": "slow",
+ "storageType": "remote"
+ },
+ "cost": "(ignore)"
+ },
+ "at": 1234
+ }
+ ],
+ "autoscalingStatus": "the autoscaling status"
}
}
} \ No newline at end of file