summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-02-27 15:21:41 +0100
committerMartin Polden <mpolden@mpolden.no>2020-02-27 15:39:24 +0100
commit0bae3e3d2d39dcda4e4b549b42a120922c544627 (patch)
treefd9582fde8356f76fa4e8252ba9a0d1856ff4154 /controller-server
parentcd00f3cf5e3ed3f78417241871ad06518a0dee46 (diff)
Remove ClusterInfoMaintainer
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java91
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java3
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainerTest.java90
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json3
4 files changed, 0 insertions, 187 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java
deleted file mode 100644
index 88c1a48653a..00000000000
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.maintenance;
-
-import com.yahoo.config.provision.ClusterSpec;
-import com.yahoo.config.provision.HostName;
-import com.yahoo.vespa.hosted.controller.Application;
-import com.yahoo.vespa.hosted.controller.Controller;
-import com.yahoo.vespa.hosted.controller.Instance;
-import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
-import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node;
-import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository;
-import com.yahoo.vespa.hosted.controller.application.ClusterInfo;
-import com.yahoo.vespa.hosted.controller.application.Deployment;
-
-import java.time.Duration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-/**
- * Maintains information about hardware, hostnames and cluster specifications.
- *
- * This is used to calculate cost metrics for the application api.
- *
- * @author smorgrav
- */
-public class ClusterInfoMaintainer extends Maintainer {
-
- private static final Logger log = Logger.getLogger(ClusterInfoMaintainer.class.getName());
-
- private final Controller controller;
- private final NodeRepository nodeRepository;
-
- ClusterInfoMaintainer(Controller controller, Duration duration, JobControl jobControl) {
- super(controller, duration, jobControl);
- this.controller = controller;
- this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository();
- }
-
- private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(List<Node> nodes) {
- Map<ClusterSpec.Id, ClusterInfo> infoMap = new HashMap<>();
-
- // Group nodes by clusterid
- Map<String, List<Node>> clusters = nodes.stream().collect(Collectors.groupingBy(Node::clusterId));
-
- // For each cluster - get info
- for (String id : clusters.keySet()) {
- List<Node> clusterNodes = clusters.get(id);
-
- // Assume they are all equal and use first node as a representative for the cluster
- Node node = clusterNodes.get(0);
-
- // Add to map
- List<String> hostnames = clusterNodes.stream()
- .map(Node::hostname)
- .map(HostName::value)
- .collect(Collectors.toList());
- ClusterInfo info = new ClusterInfo(node.flavor(), node.cost(),
- node.resources().vcpu(), node.resources().memoryGb(), node.resources().diskGb(),
- ClusterSpec.Type.from(node.clusterType().name()), hostnames);
- infoMap.put(new ClusterSpec.Id(id), info);
- }
-
- return infoMap;
- }
-
- @Override
- protected void maintain() {
- for (Application application : controller().applications().asList()) {
- for (Instance instance : application.instances().values()) {
- for (Deployment deployment : instance.deployments().values()) {
- DeploymentId deploymentId = new DeploymentId(instance.id(), deployment.zone());
- try {
- var nodes = nodeRepository.list(deploymentId.zoneId(), deploymentId.applicationId());
- Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes);
- controller().applications().lockApplicationIfPresent(application.id(), lockedApplication ->
- controller.applications().store(lockedApplication.with(instance.name(),
- locked -> locked.withClusterInfo(deployment.zone(), clusterInfo))));
- }
- catch (Exception e) {
- log.log(Level.WARNING, "Failing getting cluster information for " + deploymentId, e);
- }
- }
- }
- }
- }
-
-}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
index ec209c5ed98..18fe96fc9b2 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
@@ -32,7 +32,6 @@ public class ControllerMaintenance extends AbstractComponent {
private final VersionStatusUpdater versionStatusUpdater;
private final Upgrader upgrader;
private final ReadyJobsTrigger readyJobsTrigger;
- private final ClusterInfoMaintainer clusterInfoMaintainer;
private final DeploymentMetricsMaintainer deploymentMetricsMaintainer;
private final ApplicationOwnershipConfirmer applicationOwnershipConfirmer;
private final SystemUpgrader systemUpgrader;
@@ -64,7 +63,6 @@ public class ControllerMaintenance extends AbstractComponent {
versionStatusUpdater = new VersionStatusUpdater(controller, Duration.ofMinutes(3), jobControl);
upgrader = new Upgrader(controller, maintenanceInterval, jobControl, curator);
readyJobsTrigger = new ReadyJobsTrigger(controller, Duration.ofMinutes(1), jobControl);
- clusterInfoMaintainer = new ClusterInfoMaintainer(controller, Duration.ofHours(2), jobControl);
deploymentMetricsMaintainer = new DeploymentMetricsMaintainer(controller, Duration.ofMinutes(5), jobControl);
applicationOwnershipConfirmer = new ApplicationOwnershipConfirmer(controller, Duration.ofHours(12), jobControl, controller.serviceRegistry().ownershipIssues());
systemUpgrader = new SystemUpgrader(controller, Duration.ofMinutes(1), jobControl);
@@ -95,7 +93,6 @@ public class ControllerMaintenance extends AbstractComponent {
versionStatusUpdater.deconstruct();
upgrader.deconstruct();
readyJobsTrigger.deconstruct();
- clusterInfoMaintainer.deconstruct();
deploymentMetricsMaintainer.deconstruct();
applicationOwnershipConfirmer.deconstruct();
systemUpgrader.deconstruct();
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainerTest.java
deleted file mode 100644
index ff72a2f7231..00000000000
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainerTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.maintenance;
-
-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.NodeResources;
-import com.yahoo.config.provision.NodeType;
-import com.yahoo.config.provision.zone.ZoneId;
-import com.yahoo.vespa.hosted.controller.ControllerTester;
-import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node;
-import com.yahoo.vespa.hosted.controller.application.Deployment;
-import com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb;
-import org.junit.Test;
-
-import java.time.Duration;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author smorgrav
- */
-public class ClusterInfoMaintainerTest {
-
- private final ControllerTester tester = new ControllerTester();
-
- @Test
- public void maintain() {
- tester.createTenant("tenant1", "domain123", 321L);
- ApplicationId app = tester.createApplication("tenant1", "app1", "default").id().defaultInstance();
- ZoneId zone = ZoneId.from("dev", "us-east-1");
- tester.deploy(app, zone);
-
- // Precondition: no cluster info attached to the deployments
- Deployment deployment = tester.controller().applications().getInstance(app).get().deployments().values().stream()
- .findFirst()
- .get();
- assertEquals(0, deployment.clusterInfo().size());
-
- addNodes(zone);
- ClusterInfoMaintainer maintainer = new ClusterInfoMaintainer(tester.controller(), Duration.ofHours(1),
- new JobControl(new MockCuratorDb()));
- maintainer.maintain();
-
- deployment = tester.controller().applications().getInstance(app).get().deployments().values().stream()
- .findFirst()
- .get();
- assertEquals(2, deployment.clusterInfo().size());
- assertEquals(10, deployment.clusterInfo().get(ClusterSpec.Id.from("clusterA")).getFlavorCost());
- }
-
- private void addNodes(ZoneId zone) {
- var nodeA = new Node.Builder()
- .hostname(HostName.from("hostA"))
- .parentHostname(HostName.from("parentHostA"))
- .state(Node.State.active)
- .type(NodeType.tenant)
- .owner(ApplicationId.from("tenant1", "app1", "default"))
- .currentVersion(Version.fromString("7.42"))
- .wantedVersion(Version.fromString("7.42"))
- .currentOsVersion(Version.fromString("7.6"))
- .wantedOsVersion(Version.fromString("7.6"))
- .serviceState(Node.ServiceState.expectedUp)
- .resources(new NodeResources(1, 1, 1, 1))
- .cost(10)
- .clusterId("clusterA")
- .clusterType(Node.ClusterType.container)
- .build();
- var nodeB = new Node.Builder()
- .hostname(HostName.from("hostB"))
- .parentHostname(HostName.from("parentHostB"))
- .state(Node.State.active)
- .type(NodeType.tenant)
- .owner(ApplicationId.from("tenant1", "app1", "default"))
- .currentVersion(Version.fromString("7.42"))
- .wantedVersion(Version.fromString("7.42"))
- .currentOsVersion(Version.fromString("7.6"))
- .wantedOsVersion(Version.fromString("7.6"))
- .serviceState(Node.ServiceState.expectedUp)
- .resources(new NodeResources(1, 1, 1, 1))
- .cost(20)
- .clusterId("clusterB")
- .clusterType(Node.ClusterType.container)
- .build();
- tester.configServer().nodeRepository().addNodes(zone, List.of(nodeA, nodeB));
- }
-
-}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
index 3371c5563c9..fbdf8caaed7 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
@@ -10,9 +10,6 @@
"name": "CloudEventReporter"
},
{
- "name": "ClusterInfoMaintainer"
- },
- {
"name": "ContactInformationMaintainer"
},
{