From d7c4fe26f395c1997526fc3412cb402005889ad6 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Wed, 3 Mar 2021 20:19:45 +0100 Subject: Limit host sharing to host node type --- .../src/main/java/com/yahoo/config/provision/NodeType.java | 5 +++++ .../src/main/java/com/yahoo/vespa/hosted/provision/Node.java | 4 ++-- .../vespa/hosted/provision/provisioning/GroupPreparer.java | 10 +++++++++- .../yahoo/vespa/service/duper/ConfigServerLikeApplication.java | 1 - .../java/com/yahoo/vespa/service/duper/InfraApplication.java | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java index 63ad6ae1237..56882f8676f 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java @@ -49,6 +49,11 @@ public enum NodeType { return !childNodeTypes.isEmpty(); } + /** Returns whether this supports host sharing */ + public boolean isSharable() { + return this == NodeType.host; + } + public String description() { return description; } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java index 68caea53517..2044844e9ef 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java @@ -105,8 +105,8 @@ public final class Node implements Nodelike { if (type != NodeType.host && reservedTo.isPresent()) throw new IllegalArgumentException("Only tenant hosts can be reserved to a tenant"); - if (!type.isHost() && exclusiveTo.isPresent()) - throw new IllegalArgumentException("Only hosts can be exclusive to an application"); + if (type != NodeType.host && exclusiveTo.isPresent()) + throw new IllegalArgumentException("Only tenant hosts can be exclusive to an application"); } /** Returns the IP config of this node */ diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java index 780b080e3c9..7e4dc8d5108 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java @@ -101,9 +101,9 @@ public class GroupPreparer { } else { osVersion = nodeRepository.osVersions().targetFor(hostType).orElse(Version.emptyVersion); } + HostSharing sharing = hostSharing(requestedNodes, hostType); List provisionedHosts = allocation.nodeDeficit() .map(deficit -> { - HostSharing sharing = requestedNodes.isExclusive() ? HostSharing.exclusive : HostSharing.any; return hostProvisioner.get().provisionHosts(allocation.provisionIndices(deficit.getCount()), hostType, deficit.getFlavor(), @@ -155,4 +155,12 @@ public class GroupPreparer { return allocation; } + private static HostSharing hostSharing(NodeSpec spec, NodeType hostType) { + HostSharing sharing = spec.isExclusive() ? HostSharing.exclusive : HostSharing.any; + if (!hostType.isSharable() && sharing != HostSharing.any) { + throw new IllegalArgumentException(hostType + " does not support sharing requirement"); + } + return sharing; + } + } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerLikeApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerLikeApplication.java index b52b472d52d..91a439649a2 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerLikeApplication.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerLikeApplication.java @@ -21,7 +21,6 @@ public abstract class ConfigServerLikeApplication extends InfraApplication { return ClusterSpec.request(getClusterSpecType(), getClusterSpecId()) .vespaVersion(version) .stateful(true) - .exclusive(true) .build(); } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java index d113b34f3c6..da00ebc41e0 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java @@ -75,7 +75,7 @@ public abstract class InfraApplication implements InfraApplicationApi { @Override public ClusterSpec getClusterSpecWithVersion(Version version) { - return ClusterSpec.request(clusterSpecType, clusterSpecId).vespaVersion(version).exclusive(true).build(); + return ClusterSpec.request(clusterSpecType, clusterSpecId).vespaVersion(version).build(); } public ClusterSpec.Type getClusterSpecType() { -- cgit v1.2.3