diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2019-06-11 19:23:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-11 19:23:44 +0200 |
commit | 9111729ff3bb3de588a9d4b4c5af313155855d18 (patch) | |
tree | 55cc17af7947925273d59b6b1ba40a2fad90a2df | |
parent | f4c68c2c2428bd5ce2379cffbafa27063e6d8762 (diff) | |
parent | 7b4dabbd0e84169c591ac52de4df346a54b4b0ac (diff) |
Merge pull request #9735 from vespa-engine/freva/tenant-host-cleanup
Zone application cleanup
21 files changed, 22 insertions, 721 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java index fcc8cc8fa41..aa793b3c6a2 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java @@ -5,7 +5,6 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.ConfigModelContext; import com.yahoo.config.model.api.ConfigServerSpec; import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.log.LogLevel; import com.yahoo.vespa.model.HostResource; @@ -22,7 +21,6 @@ import org.w3c.dom.Element; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -33,8 +31,6 @@ import java.util.stream.Collectors; */ public class DomAdminV4Builder extends DomAdminBuilderBase { - private ApplicationId ZONE_APPLICATION_ID = ApplicationId.from("hosted-vespa", "routing", "default"); - private final Collection<ContainerModel> containerModels; private final ConfigModelContext context; @@ -134,34 +130,17 @@ public class DomAdminV4Builder extends DomAdminBuilderBase { * @param minHostsPerContainerCluster the desired number of hosts per cluster */ private List<HostResource> pickContainerHostsForSlobrok(int count, int minHostsPerContainerCluster) { - Collection<ContainerModel> containerModelsWithSlobrok = containerModels.stream() - .filter(this::shouldHaveSlobrok) - .collect(Collectors.toList()); int hostsPerCluster = (int) Math.max(minHostsPerContainerCluster, - Math.ceil((double) count / containerModelsWithSlobrok.size())); + Math.ceil((double) count / containerModels.size())); // Pick from all container clusters to make sure we don't lose all nodes at once if some clusters are removed. // This will overshoot the desired size (due to ceil and picking at least one node per cluster). List<HostResource> picked = new ArrayList<>(); - for (ContainerModel containerModel : containerModelsWithSlobrok) + for (ContainerModel containerModel : containerModels) picked.addAll(pickContainerHostsFrom(containerModel, hostsPerCluster)); return picked; } - private boolean shouldHaveSlobrok(ContainerModel containerModel) { - // Avoid Slobroks on node-admin container cluster, as node-admin is migrating - // TODO: Remove after removing tenant hosts from zone-app - - ApplicationId applicationId = context.getDeployState().getProperties().applicationId(); - if (!applicationId.equals(ZONE_APPLICATION_ID)) { - return true; - } - - // aka clustername, aka application-model's ClusterId - String clustername = containerModel.getCluster().getName(); - return !Objects.equals(clustername, "node-admin"); - } - private List<HostResource> pickContainerHostsFrom(ContainerModel model, int count) { boolean retired = true; List<HostResource> picked = sortedContainerHostsFrom(model, count, !retired); diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java index af31a09101e..82841b52984 100644 --- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java @@ -16,7 +16,6 @@ import com.yahoo.container.core.ApplicationMetadataConfig; import com.yahoo.search.config.QrStartConfig; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.search.core.ProtonConfig; -import com.yahoo.vespa.model.AbstractService; import com.yahoo.vespa.model.HostResource; import com.yahoo.vespa.model.HostSystem; import com.yahoo.vespa.model.VespaModel; @@ -51,9 +50,6 @@ import java.util.stream.Collectors; import static com.yahoo.config.model.test.TestUtil.joinLines; import static com.yahoo.vespa.defaults.Defaults.getDefaults; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.collection.IsIn.isIn; -import static org.hamcrest.core.Every.everyItem; -import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -762,42 +758,6 @@ public class ModelProvisioningTest { assertEquals("Included in addition because it is retired", "default03", model.getAdmin().getSlobroks().get(5).getHostName()); } - @Test - public void testSlobroksAreSpreadOverAllContainerClustersExceptNodeAdmin() { - String services = - "<?xml version='1.0' encoding='utf-8' ?>\n" + - "<services>" + - " <admin version='4.0'/>" + - " <container version='1.0' id='routing'>" + - " <nodes count='10'/>" + - " </container>" + - " <container version='1.0' id='node-admin'>" + - " <nodes count='3'/>" + - " </container>" + - "</services>"; - - int numberOfHosts = 13; - VespaModelTester tester = new VespaModelTester(); - tester.addHosts(numberOfHosts); - tester.setApplicationId("hosted-vespa", "routing", "default"); - VespaModel model = tester.createModel(services, true); - assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts)); - - Set<String> routingHosts = getClusterHostnames(model, "routing"); - assertEquals(10, routingHosts.size()); - - Set<String> nodeAdminHosts = getClusterHostnames(model, "node-admin"); - assertEquals(3, nodeAdminHosts.size()); - - Set<String> slobrokHosts = model.getAdmin().getSlobroks().stream() - .map(AbstractService::getHostName) - .collect(Collectors.toSet()); - assertEquals(3, slobrokHosts.size()); - - assertThat(slobrokHosts, everyItem(isIn(routingHosts))); - assertThat(slobrokHosts, everyItem(not(isIn(nodeAdminHosts)))); - } - private Set<String> getClusterHostnames(VespaModel model, String clusterId) { return model.getHosts().stream() .filter(host -> host.getServices().stream() diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java index 74a1eb6391b..4d0df545c39 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java @@ -7,7 +7,6 @@ import com.yahoo.component.AbstractComponent; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.model.api.PortInfo; import com.yahoo.config.model.api.ServiceInfo; -import com.yahoo.config.provision.ApplicationId; import com.yahoo.log.LogLevel; import com.yahoo.slime.Cursor; import com.yahoo.vespa.config.server.http.JSONResponse; @@ -23,13 +22,12 @@ import javax.ws.rs.client.WebTarget; import java.net.URI; import java.time.Duration; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.logging.Logger; import java.util.stream.Collectors; import static com.yahoo.config.model.api.container.ContainerServiceType.CONTAINER; @@ -44,18 +42,17 @@ import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER */ public class ConfigConvergenceChecker extends AbstractComponent { - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(ConfigConvergenceChecker.class.getName()); - private static final ApplicationId routingApplicationId = ApplicationId.from("hosted-vespa", "routing", "default"); + private static final Logger log = Logger.getLogger(ConfigConvergenceChecker.class.getName()); private static final String statePath = "/state/v1/"; private static final String configSubPath = "config"; - private final static Set<String> serviceTypesToCheck = new HashSet<>(Arrays.asList( + private final static Set<String> serviceTypesToCheck = Set.of( CONTAINER.serviceName, QRSERVER.serviceName, LOGSERVER_CONTAINER.serviceName, "searchnode", "storagenode", "distributor" - )); + ); private final StateApiFactory stateApiFactory; @@ -75,9 +72,6 @@ public class ConfigConvergenceChecker extends AbstractComponent { application.getModel().getHosts() .forEach(host -> host.getServices().stream() .filter(service -> serviceTypesToCheck.contains(service.getServiceType())) - - // TODO: Remove after removing tenant hosts from zone-app - .filter(service -> ! isHostAdminService(application.getId(), service)) .forEach(service -> getStatePort(service).ifPresent(port -> servicesToCheck.add(service)))); Map<ServiceInfo, Long> currentGenerations = getServiceGenerations(servicesToCheck, timeoutPerService); @@ -181,13 +175,6 @@ public class ConfigConvergenceChecker extends AbstractComponent { return WebResourceFactory.newResource(StateApi.class, target); } - private static boolean isHostAdminService(ApplicationId id, ServiceInfo service) { - return routingApplicationId.equals(id) - && service.getProperty("clustername") - .map("node-admin"::equals) - .orElse(false); - } - private static class ServiceListResponse extends JSONResponse { // Pre-condition: servicesToCheck has a state port diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java index f7068e7147e..906a56d3f34 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -145,11 +145,6 @@ public class Flags { "Configserver RPC authorizer. Allowed values: ['disable', 'log-only', 'enforce']", "Takes effect on restart of configserver"); - public static final UnboundBooleanFlag ENABLE_TENANT_HOST_APP = defineFeatureFlag( - "enable-tenant-host-app", false, - "Enable tenant host infrastructure application", - "Takes effect immediately"); - /** WARNING: public for testing: All flags should be defined in {@link Flags}. */ public static UnboundBooleanFlag defineFeatureFlag(String flagId, boolean defaultValue, String description, diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveExpirer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveExpirer.java index 9efde8cf673..013fd169f45 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveExpirer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveExpirer.java @@ -1,7 +1,6 @@ // 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.provision.maintenance; -import com.yahoo.config.provision.NodeType; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; import com.yahoo.vespa.hosted.provision.node.Agent; @@ -51,8 +50,7 @@ public class InactiveExpirer extends Expirer { @Override protected boolean isExpired(Node node) { return super.isExpired(node) - || node.allocation().get().owner().instance().isTester() - || node.type() == NodeType.host; // TODO: Remove after removing tenant hosts from zone-app + || node.allocation().get().owner().instance().isTester(); } } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java index 18ae7e17d6d..25549abe9ed 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java @@ -174,7 +174,7 @@ public class NodeRepositoryMaintenance extends AbstractComponent { rebootInterval = Duration.ofDays(30); nodeRetirerInterval = Duration.ofMinutes(30); metricsInterval = Duration.ofMinutes(1); - infrastructureProvisionInterval = Duration.ofMinutes(3); + infrastructureProvisionInterval = Duration.ofMinutes(1); throttlePolicy = NodeFailer.ThrottlePolicy.hosted; loadBalancerExpiry = Duration.ofHours(1); reservationExpiry = Duration.ofMinutes(20); // Need to be long enough for deployment to be finished for all config model versions diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java index 4c5310d69b6..46571fd0deb 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java @@ -13,7 +13,6 @@ import java.time.Clock; import java.time.Duration; import java.time.Instant; import java.util.LinkedHashSet; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -30,8 +29,6 @@ import java.util.stream.Collectors; */ public class OperatorChangeApplicationMaintainer extends ApplicationMaintainer { - private static final ApplicationId ZONE_APPLICATION_ID = ApplicationId.from("hosted-vespa", "routing", "default"); - private final Clock clock; private Instant previousRun; @@ -47,9 +44,9 @@ public class OperatorChangeApplicationMaintainer extends ApplicationMaintainer { Instant windowEnd = clock.instant(); Instant windowStart = previousRun; previousRun = windowEnd; - return nodeRepository().getNodes().stream() + return nodeRepository().getNodes(NodeType.tenant).stream() .filter(node -> hasManualStateChangeSince(windowStart, node)) - .flatMap(node -> owner(node).stream()) + .flatMap(node -> node.allocation().map(Allocation::owner).stream()) .collect(Collectors.toCollection(LinkedHashSet::new)); } @@ -58,13 +55,6 @@ public class OperatorChangeApplicationMaintainer extends ApplicationMaintainer { .anyMatch(event -> event.agent() == Agent.operator && event.at().isAfter(instant)); } - private Optional<ApplicationId> owner(Node node) { - if (node.allocation().isPresent()) return node.allocation().map(Allocation::owner); - - // TODO: Remove after removing tenant hosts from zone-app - return node.type() == NodeType.host ? Optional.of(ZONE_APPLICATION_ID) : Optional.empty(); - } - /** * Deploy in the maintenance thread to avoid scheduling multiple deployments of the same application if it takes * longer to deploy than the (short) maintenance interval of this diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ZoneAppMigrationTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ZoneAppMigrationTest.java deleted file mode 100644 index ffdcea973e5..00000000000 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ZoneAppMigrationTest.java +++ /dev/null @@ -1,171 +0,0 @@ -package com.yahoo.vespa.hosted.provision.maintenance; - -import com.yahoo.component.Version; -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Capacity; -import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.config.provision.HostSpec; -import com.yahoo.config.provision.NodeResources; -import com.yahoo.config.provision.NodeType; -import com.yahoo.test.ManualClock; -import com.yahoo.vespa.hosted.provision.Node; -import com.yahoo.vespa.hosted.provision.node.Agent; -import com.yahoo.vespa.hosted.provision.provisioning.ProvisioningTester; -import org.junit.Before; -import org.junit.Test; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; -import java.util.stream.Collector; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.yahoo.config.provision.ClusterSpec.Type.container; -import static com.yahoo.config.provision.ClusterSpec.Type.content; -import static org.junit.Assert.assertEquals; - -/** - * This is a temporary test to verify the requirements needed for a successful migration of tenant - * host nodes out of the zone-application. - * - * TODO: Remove after removing tenant hosts from zone-app - * - * @author freva - */ -public class ZoneAppMigrationTest { - - private final ManualClock clock = new ManualClock(); - private final ProvisioningTester tester = new ProvisioningTester.Builder().build(); - private final InactiveExpirer inactiveExpirer = new InactiveExpirer(tester.nodeRepository(), clock, Duration.ofDays(99)); - - private final Version version = Version.fromString("7.42.23"); - - private final ApplicationId zoneApp = ApplicationId.from("hosted-vespa", "routing", "default"); - private final ApplicationId proxyHostApp = ApplicationId.from("hosted-vespa", "proxy-host", "default"); - private final ApplicationId tenantHostApp = ApplicationId.from("hosted-vespa", "tenant-host", "default"); - private final ApplicationId app1 = tester.makeApplicationId(); - private final ApplicationId app2 = tester.makeApplicationId(); - - - @Test - public void tenant_host_deallocation_test() { - assertEquals(5, tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active).size()); - assertEquals(20, tester.nodeRepository().getNodes(NodeType.host, Node.State.active).size()); - assertEquals(15, tester.nodeRepository().getNodes(NodeType.tenant, Node.State.active).size()); - - Set<Node> tenantNodes = Set.copyOf(tester.nodeRepository().getNodes(NodeType.tenant)); - - // Activate zone-app with only proxy nodes, all tenant hosts become inactive, no change to other nodes - tester.activate(zoneApp, prepareSystemApplication(zoneApp, NodeType.proxy, "routing")); - assertEquals(5, tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active).size()); - assertEquals(20, tester.nodeRepository().getNodes(NodeType.host, Node.State.inactive).size()); - assertEquals(tenantNodes, Set.copyOf(tester.nodeRepository().getNodes(NodeType.tenant))); - - // All tenant hosts become dirty, no change to other nodes - inactiveExpirer.maintain(); - assertEquals(5, tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active).size()); - assertEquals(20, tester.nodeRepository().getNodes(NodeType.host, Node.State.dirty).size()); - assertEquals(tenantNodes, Set.copyOf(tester.nodeRepository().getNodes(NodeType.tenant))); - // No reboot generation incrementation - assertEquals(0, tester.nodeRepository().getNodes(NodeType.host).stream().mapToLong(node -> node.status().reboot().wanted()).sum()); - - tester.nodeRepository().getNodes(NodeType.host) - .forEach(node -> tester.nodeRepository().setReady(node.hostname(), Agent.operator, "Readied by host-admin")); - assertEquals(5, tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active).size()); - assertEquals(20, tester.nodeRepository().getNodes(NodeType.host, Node.State.ready).size()); - assertEquals(tenantNodes, Set.copyOf(tester.nodeRepository().getNodes(NodeType.tenant))); - - tester.activate(tenantHostApp, prepareSystemApplication(tenantHostApp, NodeType.host, "tenant-host")); - assertEquals(5, tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active).size()); - assertEquals(20, tester.nodeRepository().getNodes(NodeType.host, Node.State.active).size()); - assertEquals(tenantNodes, Set.copyOf(tester.nodeRepository().getNodes(NodeType.tenant))); - - // All tenant hosts are allocated to tenant host application - assertEquals(Set.copyOf(tester.nodeRepository().getNodes(NodeType.host)), - Set.copyOf(tester.nodeRepository().getNodes(tenantHostApp))); - - // All proxy nodes are still allocated to zone-app - assertEquals(Set.copyOf(tester.nodeRepository().getNodes(NodeType.proxy)), - Set.copyOf(tester.nodeRepository().getNodes(zoneApp))); - } - - @Test - public void conflicting_type_allocation_test() { - // Re-allocate tenant host from zone-app to tenant-host app - tester.activate(zoneApp, prepareSystemApplication(zoneApp, NodeType.proxy, "routing")); - inactiveExpirer.maintain(); - tester.nodeRepository().getNodes(NodeType.host) - .forEach(node -> tester.nodeRepository().setReady(node.hostname(), Agent.operator, "Readied by host-admin")); - tester.activate(tenantHostApp, prepareSystemApplication(tenantHostApp, NodeType.host, "tenant-host")); - - // Re-deploying zone-app with both type proxy and host has no effect (no tenant hosts are re-allocated from tenant-host app) - Set<Node> allNodes = Set.copyOf(tester.nodeRepository().getNodes()); - List<HostSpec> proxyHostSpecs = prepareSystemApplication(zoneApp, NodeType.proxy, "routing"); - List<HostSpec> nodeAdminHostSpecs = prepareSystemApplication(zoneApp, NodeType.host, "node-admin"); - List<HostSpec> zoneAppHostSpecs = concat(proxyHostSpecs, nodeAdminHostSpecs, Collectors.toList()); - tester.activate(zoneApp, zoneAppHostSpecs); - assertEquals(0, nodeAdminHostSpecs.size()); - assertEquals(allNodes, Set.copyOf(tester.nodeRepository().getNodes())); - - // Provision another host and redeploy zone-app - Node newHost = tester.makeReadyNodes(1, "large", NodeType.host).get(0); - proxyHostSpecs = prepareSystemApplication(zoneApp, NodeType.proxy, "routing"); - nodeAdminHostSpecs = prepareSystemApplication(zoneApp, NodeType.host, "node-admin"); - zoneAppHostSpecs = concat(proxyHostSpecs, nodeAdminHostSpecs, Collectors.toList()); - tester.activate(zoneApp, zoneAppHostSpecs); - - assertEquals(1, nodeAdminHostSpecs.size()); // The newly provisioned host is prepared - newHost = tester.nodeRepository().getNode(newHost.hostname()).orElseThrow(); // Update newHost after it has been allocated - Set<Node> allNodesWithNewHost = concat(allNodes, Set.of(newHost), Collectors.toSet()); - assertEquals(allNodesWithNewHost, Set.copyOf(tester.nodeRepository().getNodes())); - // The new host is allocated to zone-app, while the old ones are still allocated to tenant-host app - assertEquals(zoneApp, newHost.allocation().get().owner()); - } - - @Before - public void setup() { - tester.makeReadyNodes(5, "large", NodeType.proxyhost); - tester.makeReadyNodes(5, "large", NodeType.proxy); - tester.makeReadyNodes(20, "large", NodeType.host, 3); - - tester.activate(proxyHostApp, prepareSystemApplication(proxyHostApp, NodeType.proxyhost, "proxy-host")); - List<HostSpec> proxyHostSpecs = prepareSystemApplication(zoneApp, NodeType.proxy, "routing"); - List<HostSpec> nodeAdminHostSpecs = prepareSystemApplication(zoneApp, NodeType.host, "node-admin"); - List<HostSpec> zoneAppHostSpecs = concat(proxyHostSpecs, nodeAdminHostSpecs, Collectors.toList()); - tester.activate(zoneApp, zoneAppHostSpecs); - - activateTenantApplication(app1, 3, 4); - activateTenantApplication(app2, 5, 3); - } - - private List<HostSpec> prepareSystemApplication(ApplicationId applicationId, NodeType nodeType, String clusterId) { - return tester.prepare(applicationId, - ClusterSpec.request(container, ClusterSpec.Id.from(clusterId), version, false, Set.of()), - Capacity.fromRequiredNodeType(nodeType), - 1); - } - - private void activateTenantApplication(ApplicationId app, int numContainerNodes, int numContentNodes) { - List<HostSpec> combinedHostSpecs = new ArrayList<>(numContainerNodes + numContentNodes); - - combinedHostSpecs.addAll(tester.prepare(app, - ClusterSpec.request(container, ClusterSpec.Id.from("web"), version, false, Set.of()), - Capacity.fromCount(numContainerNodes, new NodeResources(2, 2, 50)), - 1)); - - combinedHostSpecs.addAll(tester.prepare(app, - ClusterSpec.request(content, ClusterSpec.Id.from("store"), version, false, Set.of()), - Capacity.fromCount(numContentNodes, new NodeResources(1, 4, 50)), - 1)); - - tester.activate(app, combinedHostSpecs); - } - - private <T, R, A> R concat(Collection<T> c1, Collection<T> c2, Collector<? super T, A, R> collector) { - return Stream.concat(c1.stream(), c2.stream()) - .collect(collector); - } -} diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java index db9fe76dc62..c53d35c16dc 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java @@ -35,11 +35,7 @@ public class VespaModelUtil { public static final ApplicationId TENANT_HOST_APPLICATION_ID = ApplicationId.from("hosted-vespa", "tenant-host", "default"); - // TODO: Remove after removing tenant hosts from zone-app - public static final ApplicationId ZONE_APPLICATION_ID = - ApplicationId.from("hosted-vespa", "routing", "default"); public static final ClusterId ADMIN_CLUSTER_ID = new ClusterId("admin"); - public static final ClusterId NODE_ADMIN_CLUSTER_ID = new ClusterId("node-admin"); public static final ServiceType SLOBROK_SERVICE_TYPE = new ServiceType("slobrok"); public static final ServiceType CLUSTER_CONTROLLER_SERVICE_TYPE = new ServiceType("container-clustercontroller"); diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicy.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicy.java index 7190473dd41..065defec1cd 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicy.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicy.java @@ -84,12 +84,6 @@ public class HostedVespaClusterPolicy implements ClusterPolicy { return ConcurrentSuspensionLimitForCluster.TWENTY_PERCENT; } - // TODO: Remove after removing tenant hosts from zone-app - if (clusterApi.getApplication().applicationId().equals(VespaModelUtil.ZONE_APPLICATION_ID) && - clusterApi.clusterId().equals(VespaModelUtil.NODE_ADMIN_CLUSTER_ID)) { - return ConcurrentSuspensionLimitForCluster.TWENTY_PERCENT; - } - return ConcurrentSuspensionLimitForCluster.TEN_PERCENT; } } diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java index 6fc826c1b5f..d834034c9a8 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java @@ -52,15 +52,6 @@ public class HostedVespaClusterPolicyTest { policy.getConcurrentSuspensionLimit(clusterApi)); } - @Test // TODO: Remove after removing tenant hosts from zone-app - public void testNodeAdminSuspensionLimit() { - when(applicationApi.applicationId()).thenReturn(VespaModelUtil.ZONE_APPLICATION_ID); - when(clusterApi.clusterId()).thenReturn(VespaModelUtil.NODE_ADMIN_CLUSTER_ID); - when(clusterApi.isStorageCluster()).thenReturn(false); - assertEquals(ConcurrentSuspensionLimitForCluster.TWENTY_PERCENT, - policy.getConcurrentSuspensionLimit(clusterApi)); - } - @Test public void testTenantHostSuspensionLimit() { when(applicationApi.applicationId()).thenReturn(VespaModelUtil.TENANT_HOST_APPLICATION_ID); diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java index eb90b2f56d7..2b72a775b24 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java @@ -9,10 +9,7 @@ import com.yahoo.config.model.api.SuperModelListener; import com.yahoo.config.model.api.SuperModelProvider; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.HostName; -import com.yahoo.config.provision.NodeType; -import com.yahoo.vespa.flags.BooleanFlag; import com.yahoo.vespa.flags.FlagSource; -import com.yahoo.vespa.flags.Flags; import com.yahoo.vespa.service.monitor.DuperModelInfraApi; import com.yahoo.vespa.service.monitor.InfraApplicationApi; @@ -40,14 +37,12 @@ public class DuperModelManager implements DuperModelInfraApi { static final TenantHostApplication tenantHostApplication = new TenantHostApplication(); private final Map<ApplicationId, InfraApplication> supportedInfraApplications; - private final Map<ApplicationId, InfraApplication> supportedMinusTenantHostInfraApplications; private final Object monitor = new Object(); private final DuperModel duperModel; // The set of active infrastructure ApplicationInfo. Not all are necessarily in the DuperModel for historical reasons. private final Set<ApplicationId> activeInfraInfos = new HashSet<>(10); - private final BooleanFlag tenantHostApplicationEnabled; @Inject public DuperModelManager(ConfigserverConfig configServerConfig, FlagSource flagSource, SuperModelProvider superModelProvider) { @@ -59,7 +54,6 @@ public class DuperModelManager implements DuperModelInfraApi { /** For testing */ DuperModelManager(boolean multitenant, boolean isController, SuperModelProvider superModelProvider, DuperModel duperModel, FlagSource flagSource) { this.duperModel = duperModel; - this.tenantHostApplicationEnabled = Flags.ENABLE_TENANT_HOST_APP.bindTo(flagSource); if (multitenant) { supportedInfraApplications = @@ -70,9 +64,6 @@ public class DuperModelManager implements DuperModelInfraApi { } else { supportedInfraApplications = Map.of(); } - supportedMinusTenantHostInfraApplications = supportedInfraApplications.entrySet().stream() - .filter(app -> app.getValue().getCapacity().type() != NodeType.host) - .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)); superModelProvider.registerListener(new SuperModelListener() { @Override @@ -103,23 +94,16 @@ public class DuperModelManager implements DuperModelInfraApi { @Override public List<InfraApplicationApi> getSupportedInfraApplications() { - return new ArrayList<>(getSupportedApps().values()); + return new ArrayList<>(supportedInfraApplications.values()); } @Override public Optional<InfraApplicationApi> getInfraApplication(ApplicationId applicationId) { - return Optional.ofNullable(getSupportedApps().get(applicationId)); - } - - private Map<ApplicationId, InfraApplication> getSupportedApps() { - return tenantHostApplicationEnabled.value() ? supportedInfraApplications : supportedMinusTenantHostInfraApplications; + return Optional.ofNullable(supportedInfraApplications.get(applicationId)); } /** * Returns true if application is considered an infrastructure application by the DuperModel. - * - * <p>Note: Unless enable-tenant-host-app flag is enabled, the tenant host "application" is NOT considered an - * infrastructure application: It is just a cluster in the {@link ZoneApplication zone application}. */ public boolean isSupportedInfraApplication(ApplicationId applicationId) { return supportedInfraApplications.containsKey(applicationId); diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java deleted file mode 100644 index bcf5f096e7f..00000000000 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.service.duper; - -import com.yahoo.config.model.api.ServiceInfo; -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.ApplicationName; -import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.config.provision.NodeType; -import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.applicationmodel.ClusterId; -import com.yahoo.vespa.applicationmodel.ServiceType; -import com.yahoo.vespa.service.model.ApplicationInstanceGenerator; - -import java.util.Objects; - -/** - * @author hakon - * - * TODO: This does not extend InfraApplication because - * 1) It is not deployed same as the other HostedVespaApplications - * 2) ZoneApplication has multiple clusters - */ -public class ZoneApplication { - - private ZoneApplication() {} - - private static final ApplicationId ZONE_APPLICATION_ID = InfraApplication - .createHostedVespaApplicationId("routing"); - private static final ClusterId NODE_ADMIN_CLUSTER_ID = new ClusterId("node-admin"); - private static final ClusterId ROUTING_CLUSTER_ID = new ClusterId("routing"); - - public static ApplicationId getApplicationId() { - return ZONE_APPLICATION_ID; - } - - public static TenantName getTenantName() { - return ZONE_APPLICATION_ID.tenant(); - } - - public static ApplicationName getApplicationName() { - return ZONE_APPLICATION_ID.application(); - } - - public static NodeType getNodeAdminNodeType() { - return NodeType.host; - } - - public static ClusterId getNodeAdminClusterId() { - return NODE_ADMIN_CLUSTER_ID; - } - - public static ClusterSpec.Type getNodeAdminClusterSpecType() { - return ClusterSpec.Type.container; - } - - public static ClusterSpec.Id getNodeAdminClusterSpecId() { - return new ClusterSpec.Id(getNodeAdminClusterId().s()); - } - - public static ServiceType getNodeAdminServiceType() { - return ServiceType.CONTAINER; - } - - public static int getNodeAdminHealthPort() { - return HostAdminApplication.HOST_ADMIN_HEALT_PORT; - } - - public static NodeType getRoutingNodeType() { - return NodeType.proxy; - } - - public static ClusterId getRoutingClusterId() { - return ROUTING_CLUSTER_ID; - } - - public static ClusterSpec.Type getRoutingClusterSpecType() { - return ClusterSpec.Type.container; - } - - public static ClusterSpec.Id getRoutingClusterSpecId() { - return new ClusterSpec.Id(getRoutingClusterId().s()); - } - - public static ServiceType getRoutingServiceType() { - return ServiceType.CONTAINER; - } - - public static int getRoutingHealthPort() { - return 4088; - } - - public static boolean isNodeAdminService(ApplicationId applicationId, - ClusterId clusterId, - ServiceType serviceType) { - return Objects.equals(applicationId, getApplicationId()) && - Objects.equals(serviceType, getNodeAdminServiceType()) && - Objects.equals(clusterId, getNodeAdminClusterId()); - } - - /** Whether a {@link ServiceInfo} belongs to the zone application's node-admin cluster. */ - public static boolean isNodeAdminServiceInfo(ApplicationId applicationId, ServiceInfo serviceInfo) { - return isNodeAdminService( - applicationId, - ApplicationInstanceGenerator.getClusterId(serviceInfo), - ApplicationInstanceGenerator.toServiceType(serviceInfo)); - } - -} diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitorManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitorManager.java index 7601cfd2e95..3cc7010e209 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitorManager.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitorManager.java @@ -10,7 +10,6 @@ import com.yahoo.vespa.applicationmodel.ServiceStatus; import com.yahoo.vespa.applicationmodel.ServiceStatusInfo; import com.yahoo.vespa.applicationmodel.ServiceType; import com.yahoo.vespa.service.duper.DuperModelManager; -import com.yahoo.vespa.service.duper.ZoneApplication; import com.yahoo.vespa.service.executor.RunletExecutorImpl; import com.yahoo.vespa.service.manager.HealthMonitorApi; import com.yahoo.vespa.service.manager.MonitorManager; @@ -77,7 +76,7 @@ public class HealthMonitorManager implements MonitorManager, HealthMonitorApi { @Override public void applicationActivated(ApplicationInfo application) { - if (wouldMonitor(application.getApplicationId())) { + if (duperModel.isSupportedInfraApplication(application.getApplicationId())) { healthMonitors .computeIfAbsent(application.getApplicationId(), applicationHealthMonitorFactory::create) .monitor(application); @@ -103,24 +102,9 @@ public class HealthMonitorManager implements MonitorManager, HealthMonitorApi { return new ServiceStatusInfo(ServiceStatus.NOT_CHECKED); } - if (applicationId.equals(ZoneApplication.getApplicationId())) { - // New: The zone app is health monitored (monitor != null), possibly even the routing cluster - // which is a normal jdisc container (unnecessary but harmless), but the node-admin cluster - // are tenant Docker hosts running host admin that are monitored via /state/v1/health. - if (ZoneApplication.isNodeAdminService(applicationId, clusterId, serviceType)) { - return monitor.getStatus(applicationId, clusterId, serviceType, configId); - } else { - return new ServiceStatusInfo(ServiceStatus.NOT_CHECKED); - } - } - return monitor.getStatus(applicationId, clusterId, serviceType, configId); } - private boolean wouldMonitor(ApplicationId id) { - return duperModel.isSupportedInfraApplication(id) || id.equals(ZoneApplication.getApplicationId()); - } - @Override public List<ApplicationId> getMonitoredApplicationIds() { return Collections.list(healthMonitors.keys()); diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java index 8e3780744f6..0408e0134ea 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java @@ -6,14 +6,11 @@ import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.model.api.PortInfo; import com.yahoo.config.model.api.ServiceInfo; import com.yahoo.config.provision.HostName; -import com.yahoo.vespa.service.duper.HostAdminApplication; -import com.yahoo.vespa.service.duper.ZoneApplication; import com.yahoo.vespa.service.executor.RunletExecutor; import com.yahoo.vespa.service.model.ApplicationInstanceGenerator; import com.yahoo.vespa.service.monitor.ServiceId; import java.time.Duration; -import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -28,7 +25,7 @@ public class StateV1HealthModel implements AutoCloseable { private static final String PORT_TAG_HTTP = "HTTP"; /** Port tags implying /state/v1/health is served on HTTP. */ - public static final List<String> HTTP_HEALTH_PORT_TAGS = Arrays.asList(PORT_TAG_HTTP, PORT_TAG_STATE); + public static final List<String> HTTP_HEALTH_PORT_TAGS = List.of(PORT_TAG_HTTP, PORT_TAG_STATE); private final Duration targetHealthStaleness; private final Duration requestTimeout; private final Duration connectionKeepAlive; @@ -47,32 +44,16 @@ public class StateV1HealthModel implements AutoCloseable { Map<ServiceId, HealthEndpoint> extractHealthEndpoints(ApplicationInfo application) { Map<ServiceId, HealthEndpoint> endpoints = new HashMap<>(); - boolean isZoneApplication = application.getApplicationId().equals(ZoneApplication.getApplicationId()); - for (HostInfo hostInfo : application.getModel().getHosts()) { HostName hostname = HostName.from(hostInfo.getHostname()); for (ServiceInfo serviceInfo : hostInfo.getServices()) { - - boolean isNodeAdmin = false; - if (isZoneApplication) { - if (ZoneApplication.isNodeAdminServiceInfo(application.getApplicationId(), serviceInfo)) { - isNodeAdmin = true; - } else { - // Only the node admin/host admin cluster of the zone application should be monitored - // TODO: Move the node admin cluster out to a separate infrastructure application - continue; - } - } - ServiceId serviceId = ApplicationInstanceGenerator.getServiceId(application, serviceInfo); for (PortInfo portInfo : serviceInfo.getPorts()) { if (portTaggedWith(portInfo, HTTP_HEALTH_PORT_TAGS)) { - // The host-admin-in-zone-application is one big hack. - int port = isNodeAdmin ? HostAdminApplication.HOST_ADMIN_HEALT_PORT : portInfo.getPort(); StateV1HealthEndpoint endpoint = new StateV1HealthEndpoint( serviceId, hostname, - port, + portInfo.getPort(), targetHealthStaleness, requestTimeout, connectionKeepAlive, diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/model/ApplicationInstanceGenerator.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ApplicationInstanceGenerator.java index e535aff8b46..5cc2d538c24 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/model/ApplicationInstanceGenerator.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ApplicationInstanceGenerator.java @@ -4,7 +4,6 @@ package com.yahoo.vespa.service.model; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.model.api.ServiceInfo; -import com.yahoo.config.model.api.container.ContainerServiceType; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Zone; import com.yahoo.vespa.applicationmodel.ApplicationInstance; @@ -19,7 +18,6 @@ import com.yahoo.vespa.applicationmodel.ServiceStatusInfo; import com.yahoo.vespa.applicationmodel.ServiceType; import com.yahoo.vespa.applicationmodel.TenantId; import com.yahoo.vespa.service.duper.ConfigServerApplication; -import com.yahoo.vespa.service.duper.ZoneApplication; import com.yahoo.vespa.service.monitor.ServiceId; import com.yahoo.vespa.service.monitor.ServiceStatusProvider; @@ -56,20 +54,9 @@ public class ApplicationInstanceGenerator { for (HostInfo host : applicationInfo.getModel().getHosts()) { HostName hostName = new HostName(host.getHostname()); - boolean isTenantHost = - applicationInfo.getApplicationId().equals(ZoneApplication.getApplicationId()) && - host.getServices().stream().anyMatch(serviceInfo -> - ZoneApplication.isNodeAdminServiceInfo(applicationInfo.getApplicationId(), serviceInfo)); - for (ServiceInfo serviceInfo : host.getServices()) { ServiceClusterKey serviceClusterKey = toServiceClusterKey(serviceInfo); - if (isTenantHost && !ZoneApplication.isNodeAdminServiceInfo(applicationInfo.getApplicationId(), serviceInfo)) { - // A tenant host only runs the host-admin service, even though the model contains a bunch of - // standard services like config-sentinel and metrics proxy. - continue; - } - ServiceInstance serviceInstance = toServiceInstance( applicationInfo.getApplicationId(), @@ -78,9 +65,7 @@ public class ApplicationInstanceGenerator { hostName, serviceStatusProvider); - if (!groupedServiceInstances.containsKey(serviceClusterKey)) { - groupedServiceInstances.put(serviceClusterKey, new HashSet<>()); - } + groupedServiceInstances.putIfAbsent(serviceClusterKey, new HashSet<>()); groupedServiceInstances.get(serviceClusterKey).add(serviceInstance); } } diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/TestZoneApplication.java b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/TestZoneApplication.java deleted file mode 100644 index 773643c1d09..00000000000 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/TestZoneApplication.java +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.service.duper; - -import com.yahoo.config.model.api.ApplicationInfo; -import com.yahoo.config.model.api.HostInfo; -import com.yahoo.config.provision.HostName; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @author hakonhall - */ -public class TestZoneApplication { - - private final List<HostName> nodeAdminHostnames; - private final List<HostName> routingHostnames; - - private TestZoneApplication(List<HostName> nodeAdminHostnames, List<HostName> routingHostnames) { - this.nodeAdminHostnames = nodeAdminHostnames; - this.routingHostnames = routingHostnames; - } - - public ApplicationInfo makeApplicationInfo() { - // Make a test ApplicationInfo by: - // 1. Make an ApplicationInfo as-if the node-admin cluster of the zone application were the only cluster. - // Make sure to get the correct tenant name, application name, cluster id, service type, hostnames, - // services, and ports. This should be easy with the help of InfraApplication. - ApplicationInfo nodeAdminPart = new NodeAdminPartOfZoneApplication().makeApplicationInfo(nodeAdminHostnames); - - // 2. Make an ApplicationInfo as-if the routing cluster of the zone application were the only cluster. - // Don't care if the application is not perfect. - ApplicationInfo routingPart = new RoutingPartOfZoneApplication().makeApplicationInfo(routingHostnames); - - // 3. Take HostInfo from (1) and (2) to make a single ApplicationInfo. - List<HostInfo> allHostInfos = new ArrayList<>(); - allHostInfos.addAll(nodeAdminPart.getModel().getHosts()); - allHostInfos.addAll(routingPart.getModel().getHosts()); - - return new ApplicationInfo(nodeAdminPart.getApplicationId(), 0, new HostsModel(allHostInfos)); - } - - public static class Builder { - private List<HostName> nodeAdminHostnames = null; - private List<HostName> routingHostnames = null; - - public Builder addNodeAdminCluster(String... hostnames) { - this.nodeAdminHostnames = Stream.of(hostnames).map(HostName::from).collect(Collectors.toList()); - return this; - } - - public Builder addRoutingCluster(String... hostnames) { - this.routingHostnames = Stream.of(hostnames).map(HostName::from).collect(Collectors.toList()); - return this; - } - - public TestZoneApplication build() { - return new TestZoneApplication(Objects.requireNonNull(nodeAdminHostnames), Objects.requireNonNull(routingHostnames)); - } - } - - private static class NodeAdminPartOfZoneApplication extends InfraApplication { - public NodeAdminPartOfZoneApplication() { - super(ZoneApplication.getApplicationName().value(), - ZoneApplication.getNodeAdminNodeType(), - ZoneApplication.getNodeAdminClusterSpecType(), - ZoneApplication.getNodeAdminClusterSpecId(), - ZoneApplication.getNodeAdminServiceType(), - ZoneApplication.getNodeAdminHealthPort()); - } - } - - /** - * This InfraApplication is bogus (containing host admin instead of jdisc container), but the tests are - * not supposed to explore this cluster. - */ - private static class RoutingPartOfZoneApplication extends InfraApplication { - public RoutingPartOfZoneApplication() { - super(ZoneApplication.getApplicationName().value(), - ZoneApplication.getRoutingNodeType(), - ZoneApplication.getRoutingClusterSpecType(), - ZoneApplication.getRoutingClusterSpecId(), - ZoneApplication.getRoutingServiceType(), - ZoneApplication.getRoutingHealthPort()); - } - } -} diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java index 89bcda05074..008a271f905 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java @@ -3,15 +3,12 @@ package com.yahoo.vespa.service.health; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.provision.HostName; -import com.yahoo.vespa.applicationmodel.ConfigId; import com.yahoo.vespa.applicationmodel.ServiceStatus; import com.yahoo.vespa.applicationmodel.ServiceStatusInfo; import com.yahoo.vespa.service.duper.ControllerHostApplication; import com.yahoo.vespa.service.duper.DuperModelManager; import com.yahoo.vespa.service.duper.InfraApplication; import com.yahoo.vespa.service.duper.ProxyHostApplication; -import com.yahoo.vespa.service.duper.TestZoneApplication; -import com.yahoo.vespa.service.duper.ZoneApplication; import com.yahoo.vespa.service.monitor.ConfigserverUtil; import org.junit.Before; import org.junit.Test; @@ -22,7 +19,6 @@ import java.util.stream.Stream; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -49,62 +45,6 @@ public class HealthMonitorManagerTest { } @Test - public void verifyZoneApplicationIsMonitored() { - ApplicationInfo zoneApplicationInfo = new TestZoneApplication.Builder() - .addNodeAdminCluster("h1", "h2") - .addRoutingCluster("r1") - .build() - .makeApplicationInfo(); - - verify(monitorFactory, times(0)).create(zoneApplicationInfo.getApplicationId()); - verify(monitor, times(0)).monitor(any()); - manager.applicationActivated(zoneApplicationInfo); - verify(monitorFactory).create(zoneApplicationInfo.getApplicationId()); - verify(monitor).monitor(any()); - - when(monitor.getStatus(any(), any(), any(), any())).thenReturn(new ServiceStatusInfo(ServiceStatus.DOWN)); - verifyNodeAdminGetStatus(0); - assertEquals(ServiceStatus.DOWN, getNodeAdminStatus()); - verifyNodeAdminGetStatus(1); - - verifyRoutingGetStatus(0); - assertEquals(ServiceStatus.NOT_CHECKED, getRoutingStatus()); - verifyRoutingGetStatus(0); - } - - private void verifyNodeAdminGetStatus(int invocations) { - verify(monitor, times(invocations)).getStatus( - eq(ZoneApplication.getApplicationId()), - eq(ZoneApplication.getNodeAdminClusterId()), - any(), - any()); - } - - private void verifyRoutingGetStatus(int invocations) { - verify(monitor, times(invocations)).getStatus( - eq(ZoneApplication.getApplicationId()), - eq(ZoneApplication.getRoutingClusterId()), - any(), - any()); - } - - private ServiceStatus getNodeAdminStatus() { - return manager.getStatus( - ZoneApplication.getApplicationId(), - ZoneApplication.getNodeAdminClusterId(), - ZoneApplication.getNodeAdminServiceType(), - new ConfigId("foo")).serviceStatus(); - } - - private ServiceStatus getRoutingStatus() { - return manager.getStatus( - ZoneApplication.getApplicationId(), - ZoneApplication.getRoutingClusterId(), - ZoneApplication.getRoutingServiceType(), - new ConfigId("bar")).serviceStatus(); - } - - @Test public void infrastructureApplication() { ProxyHostApplication proxyHostApplication = new ProxyHostApplication(); when(duperModel.isSupportedInfraApplication(proxyHostApplication.getApplicationId())).thenReturn(true); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java index 3fce1cca899..a7f632a2084 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java @@ -10,8 +10,6 @@ import com.yahoo.vespa.applicationmodel.ConfigId; import com.yahoo.vespa.applicationmodel.ServiceStatus; import com.yahoo.vespa.applicationmodel.ServiceType; import com.yahoo.vespa.service.duper.ProxyHostApplication; -import com.yahoo.vespa.service.duper.TestZoneApplication; -import com.yahoo.vespa.service.duper.ZoneApplication; import com.yahoo.vespa.service.executor.Cancellable; import com.yahoo.vespa.service.executor.RunletExecutor; import com.yahoo.vespa.service.monitor.ServiceId; @@ -71,24 +69,6 @@ public class StateV1HealthModelTest { } @Test - public void testMonitoringTenantHostHealth() { - ApplicationInfo zoneApplicationInfo = new TestZoneApplication.Builder() - .addNodeAdminCluster("h1") - .addRoutingCluster("r1") - .build() - .makeApplicationInfo(); - - Map<ServiceId, HealthEndpoint> endpoints = model.extractHealthEndpoints(zoneApplicationInfo); - assertEquals(1, endpoints.size()); - HealthEndpoint endpoint = endpoints.values().iterator().next(); - assertEquals("http://h1:8080/state/v1/health", endpoint.description()); - ServiceId serviceId = endpoint.getServiceId(); - assertEquals(ZoneApplication.getApplicationId(), serviceId.getApplicationId()); - assertEquals(ZoneApplication.getNodeAdminClusterId(), serviceId.getClusterId()); - assertEquals(ZoneApplication.getNodeAdminServiceType(), serviceId.getServiceType()); - } - - @Test public void caseInsensitiveTagMatching() { PortInfo portInfo = mock(PortInfo.class); when(portInfo.getTags()).thenReturn(List.of("http", "STATE", "foo")); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java index 5cfe70fae5f..f6ef3977a56 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.service.manager; import com.yahoo.vespa.applicationmodel.ConfigId; import com.yahoo.vespa.applicationmodel.ServiceStatus; import com.yahoo.vespa.applicationmodel.ServiceStatusInfo; -import com.yahoo.vespa.service.duper.ZoneApplication; +import com.yahoo.vespa.service.duper.ConfigServerHostApplication; import com.yahoo.vespa.service.health.HealthMonitorManager; import com.yahoo.vespa.service.slobrok.SlobrokMonitorManagerImpl; import org.junit.Test; @@ -18,6 +18,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class UnionMonitorManagerTest { + private final ConfigServerHostApplication application = new ConfigServerHostApplication(); private final SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class); private final HealthMonitorManager healthMonitorManager = mock(HealthMonitorManager.class); @@ -38,9 +39,9 @@ public class UnionMonitorManagerTest { when(healthMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(new ServiceStatusInfo(healthStatus)); when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(new ServiceStatusInfo(slobrokStatus)); ServiceStatus status = manager.getStatus( - ZoneApplication.getApplicationId(), - ZoneApplication.getNodeAdminClusterId(), - ZoneApplication.getNodeAdminServiceType(), new ConfigId("config-id")).serviceStatus(); + application.getApplicationId(), + application.getClusterId(), + application.getServiceType(), new ConfigId("config-id")).serviceStatus(); assertSame(expectedStatus, status); } }
\ No newline at end of file diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java index e182c9d6468..4810f29b28f 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java @@ -2,32 +2,19 @@ package com.yahoo.vespa.service.model; import com.yahoo.config.model.api.ApplicationInfo; -import com.yahoo.config.model.api.HostInfo; -import com.yahoo.config.model.api.Model; -import com.yahoo.config.model.api.ServiceInfo; -import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; -import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.Zone; import com.yahoo.vespa.applicationmodel.ApplicationInstance; -import com.yahoo.vespa.applicationmodel.ClusterId; -import com.yahoo.vespa.applicationmodel.ServiceCluster; import com.yahoo.vespa.applicationmodel.ServiceStatus; import com.yahoo.vespa.applicationmodel.ServiceStatusInfo; import com.yahoo.vespa.service.duper.ConfigServerApplication; -import com.yahoo.vespa.service.duper.ZoneApplication; import com.yahoo.vespa.service.monitor.ServiceStatusProvider; import org.junit.Test; import java.util.List; -import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; @@ -37,10 +24,7 @@ public class ApplicationInstanceGeneratorTest { private static final String configServer1 = "cfg1.yahoo.com"; private static final String configServer2 = "cfg2.yahoo.com"; private static final String configServer3 = "cfg3.yahoo.com"; - private static final List<String> configServerList = Stream.of( - configServer1, - configServer2, - configServer3).collect(Collectors.toList()); + private static final List<String> configServerList = List.of(configServer1, configServer2, configServer3); private static final ConfigServerApplication configServerApplication = new ConfigServerApplication(); private final ServiceStatusProvider statusProvider = mock(ServiceStatusProvider.class); @@ -84,63 +68,4 @@ public class ApplicationInstanceGeneratorTest { .hostName() .toString())); } - - @Test - public void verifyOnlyNodeAdminServiceIsLeft() { - when(statusProvider.getStatus(any(), any(), any(), any())).thenReturn(new ServiceStatusInfo(ServiceStatus.NOT_CHECKED)); - - String host1 = "host1"; - String host2 = "host2"; - - List<ServiceInfo> serviceInfos1 = List.of( - makeServiceInfo("metrics", "metricsproxy-container", host1) - ); - - List<ServiceInfo> serviceInfos2 = List.of( - makeServiceInfo("metrics", "metricsproxy-container", host2), - makeServiceInfo(ZoneApplication.getNodeAdminClusterId().s(), - ZoneApplication.getNodeAdminServiceType().s(), host2) - ); - - List<HostInfo> hostInfos = List.of( - new HostInfo(host1, serviceInfos1), - new HostInfo(host2, serviceInfos2) - ); - - Model model = mock(Model.class); - when(model.getHosts()).thenReturn(hostInfos); - - ApplicationInfo applicationInfo = new ApplicationInfo(ZoneApplication.getApplicationId(), 0, model); - - Zone zone = mock(Zone.class); - when(zone.environment()).thenReturn(Environment.prod); - when(zone.region()).thenReturn(RegionName.from("us-east-1")); - - ApplicationInstanceGenerator generator = new ApplicationInstanceGenerator(applicationInfo, zone); - ApplicationInstance applicationInstance = generator.makeApplicationInstance(statusProvider); - - Map<ClusterId, List<ServiceCluster>> serviceClusters = - applicationInstance.serviceClusters().stream().collect(Collectors.groupingBy(ServiceCluster::clusterId)); - assertEquals(2, serviceClusters.size()); - List<ServiceCluster> nodeAdminClusters = serviceClusters.get(ZoneApplication.getNodeAdminClusterId()); - assertNotNull(nodeAdminClusters); - assertEquals(1, nodeAdminClusters.size()); - ServiceCluster nodeAdminCluster = nodeAdminClusters.iterator().next(); - assertEquals(1, nodeAdminCluster.serviceInstances().size()); - assertEquals(host2, nodeAdminCluster.serviceInstances().iterator().next().hostName().s()); - - List<ServiceCluster> metricsClusters = serviceClusters.get(new ClusterId("metrics")); - assertNotNull(metricsClusters); - assertEquals(1, metricsClusters.size()); - ServiceCluster metricsCluster = metricsClusters.iterator().next(); - - // The metrics service on the node admin host is ignored - assertEquals(1, metricsCluster.serviceInstances().size()); - assertEquals(host1, metricsCluster.serviceInstances().iterator().next().hostName().s()); - } - - private ServiceInfo makeServiceInfo(String clusterId, String serviceType, String hostname) { - var properties = Map.of(ApplicationInstanceGenerator.CLUSTER_ID_PROPERTY_NAME, clusterId); - return new ServiceInfo("servicename", serviceType, List.of(), properties, "configid", hostname); - } }
\ No newline at end of file |