diff options
author | Håkon Hallingstad <hakon@oath.com> | 2018-02-28 10:40:40 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@oath.com> | 2018-02-28 10:40:40 +0100 |
commit | bdaf016ddd701df11646f234ea3536867c875e3d (patch) | |
tree | b9163397d0aae031f1f8e289bb30639904ee686f /config-model | |
parent | c2d3acc84c102d9cc91ea8d71d607b16220ab58d (diff) |
Avoid Slobrok in node-admin cluster
When this rolls out, two Slobroks on the node-admin will be removed, and 1
additional Slobrok will be put on one of the proxy nodes if the routing cluster
has 3 or more nodes.
The Orchestrator sees the latest model, i.e. expect 3 Slobroks on the proxy
nodes. Since the 1 additional Slobrok service is down at the start of the
rollout, only that host will be allowed to suspend among the 3. But if that 1
additional Slobrok service comes up quickly, then any of the 3 can suspend. I
think this will just work - no deadlocks or similar.
I couldn't find any test that would covers this code change, but will write
tests if someone can help me with this, if deemed necessary.
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java | 41 |
1 files changed, 31 insertions, 10 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 cc9957144f3..44de53991f4 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 @@ -2,22 +2,23 @@ package com.yahoo.vespa.model.builder.xml.dom; import com.yahoo.component.Version; +import com.yahoo.config.model.ConfigModelContext; import com.yahoo.config.model.api.ConfigServerSpec; +import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.vespa.model.HostResource; import com.yahoo.vespa.model.HostSystem; -import com.yahoo.vespa.model.admin.*; -import com.yahoo.config.model.ConfigModelContext; import com.yahoo.vespa.model.admin.Admin; +import com.yahoo.vespa.model.admin.Logserver; +import com.yahoo.vespa.model.admin.Slobrok; import com.yahoo.vespa.model.container.Container; import com.yahoo.vespa.model.container.ContainerModel; - import org.w3c.dom.Element; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -27,6 +28,7 @@ import java.util.stream.Collectors; * @author bratseth */ 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; @@ -63,7 +65,7 @@ public class DomAdminV4Builder extends DomAdminBuilderBase { createSlobroks(admin, allocateHosts(admin.getHostSystem(), "slobroks", nodesSpecification)); } else { - createSlobroks(admin, pickContainerHosts(nodesSpecification.count(), 2)); + createSlobroks(admin, pickContainerHostsForSlobrok(nodesSpecification.count(), 2)); } } @@ -94,17 +96,36 @@ public class DomAdminV4Builder extends DomAdminBuilderBase { * on topology changes, and less nodes may be returned if fewer are available * @param minHostsPerContainerCluster the desired number of hosts per cluster */ - private List<HostResource> pickContainerHosts(int count, int minHostsPerContainerCluster) { + 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())); + // 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 : containerModels) - picked.addAll(pickContainerHostsFrom(containerModel, - (int) Math.max(minHostsPerContainerCluster, - Math.ceil((double) count / containerModels.size())))); + for (ContainerModel containerModel : containerModelsWithSlobrok) + 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 this hack once node-admin has migrated out the 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); |