summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-10-12 19:56:37 +0200
committerjonmv <venstad@gmail.com>2023-10-12 19:56:37 +0200
commit8aafd0694bb884ec8ac69b0bb70acb44ce69fb8b (patch)
treefd793d80801f57f6d16af98a79fba8cc4b6d4e02 /node-repository
parent8d472a52c97fe359d770e61a6e70d2d75987890f (diff)
Always check host exclusiveTo
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java5
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java33
2 files changed, 36 insertions, 2 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java
index 5ab7e032dc5..05aa986b9ff 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java
@@ -568,12 +568,13 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat
if (parentHostname().isEmpty()) return false;
if (type() != NodeType.tenant) return false;
+ // We always violate exclusivity if the parent is exclusive to someone else that the requesting application.
+ if ( ! emptyOrEqual(parent.flatMap(Node::exclusiveToApplicationId), application)) return true;
+
// In zones which do not allow host sharing, exclusivity is violated if...
if ( ! hostSharing) {
// If either the parent is dedicated to a cluster type different from this cluster
return ! emptyOrEqual(parent.flatMap(Node::exclusiveToClusterType), cluster.type()) ||
- // or the parent is dedicated to a different application
- ! emptyOrEqual(parent.flatMap(Node::exclusiveToApplicationId), application) ||
// or this cluster requires exclusivity, but the host is not exclusive (to this, implicitly by the above).
exclusiveCluster && parent.flatMap(Node::exclusiveToApplicationId).isEmpty();
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
index bb30e0d985e..f960b122d24 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
@@ -278,6 +278,39 @@ public class HostCapacityMaintainerTest {
}
@Test
+ public void respects_exclusive_allocation() {
+ tester = new DynamicProvisioningTester();
+ NodeResources resources1 = new NodeResources(24, 64, 100, 10);
+ setPreprovisionCapacityFlag(tester,
+ new ClusterCapacity(2, resources1.vcpu(), resources1.memoryGb(), resources1.diskGb(),
+ resources1.bandwidthGbps(), resources1.diskSpeed().name(),
+ resources1.storageType().name(), resources1.architecture().name(),
+ null));
+ tester.maintain();
+
+ // Hosts are provisioned
+ assertEquals(2, tester.provisionedHostsMatching(resources1));
+ assertEquals(0, tester.hostProvisioner.deprovisionedHosts());
+
+ // Next maintenance run does nothing
+ tester.assertNodesUnchanged();
+
+ // One host is allocated exclusively to some other application
+ tester.nodeRepository.nodes().write(tester.nodeRepository.nodes().list().node("host100").get()
+ .withExclusiveToApplicationId(ApplicationId.from("t", "a", "i")),
+ () -> { });
+
+ tester.maintain();
+
+ // New hosts are provisioned, and the empty exclusive host is deallocated
+ assertEquals(2, tester.provisionedHostsMatching(resources1));
+ assertEquals(1, tester.hostProvisioner.deprovisionedHosts());
+
+ // Next maintenance run does nothing
+ tester.assertNodesUnchanged();
+ }
+
+ @Test
public void test_minimum_capacity() {
tester = new DynamicProvisioningTester();
NodeResources resources1 = new NodeResources(24, 64, 100, 10);