diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-03-21 11:13:11 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-03-21 11:13:11 +0100 |
commit | 5366643befc4f8920af2d66499d5a8d7654721a5 (patch) | |
tree | 517bf707bcf013db4e437942c6b6cb737603bb85 /node-repository | |
parent | 62b81908c1fd922dcf397e99c4a79f5e73fffcfd (diff) |
Allow applications of the same tenant on the same host when exclusive
Diffstat (limited to 'node-repository')
2 files changed, 16 insertions, 15 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java index 4df8b5ba04f..9f24d25ed81 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.provision.provisioning; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.ClusterSpec; +import com.yahoo.config.provision.TenantName; import com.yahoo.lang.MutableInteger; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; @@ -98,7 +99,8 @@ class NodeAllocation { if ( ! hasCompatibleFlavor(offered)) wantToRetireNode = true; if ( offered.flavor().isRetired()) wantToRetireNode = true; if ( offered.status().wantToRetire()) wantToRetireNode = true; - if ( requestedNodes.isExclusive() && ! hostHasOnly(application, offered.parentHostname())) wantToRetireNode = true; + if ( requestedNodes.isExclusive() && + ! hostHasOnly(application.tenant(), offered.parentHostname())) wantToRetireNode = true; if (( ! saturated() && hasCompatibleFlavor(offered)) || acceptToRetire(offered) ) { accepted.add(acceptNode(offeredPriority, wantToRetireNode)); @@ -109,11 +111,11 @@ class NodeAllocation { ++rejectedWithClashingParentHost; continue; } - if ( ! hostCanHost(application, offered.parentHostname())) { + if ( ! hostCanHost(application.tenant(), offered.parentHostname())) { ++rejectedDueToExclusivity; continue; } - if ( requestedNodes.isExclusive() && ! hostHasOnly(application, offered.parentHostname())) { + if ( requestedNodes.isExclusive() && ! hostHasOnly(application.tenant(), offered.parentHostname())) { ++rejectedDueToExclusivity; continue; } @@ -144,27 +146,27 @@ class NodeAllocation { } /** - * If a parent host is given, and it hosts another application which requires exclusive access to the physical - * host, then we cannot host this application on it. + * If a parent host is given, and it hosts another tenant with an application which requires exclusive access + * to the physical host, then we cannot host this application on it. */ - private boolean hostCanHost(ApplicationId application, Optional<String> parentHostname) { + private boolean hostCanHost(TenantName tenant, Optional<String> parentHostname) { if ( ! parentHostname.isPresent()) return true; for (Node nodeOnHost : nodeRepository.getChildNodes(parentHostname.get())) { if ( ! nodeOnHost.allocation().isPresent()) continue; if ( nodeOnHost.allocation().get().membership().cluster().isExclusive() && - ! nodeOnHost.allocation().get().owner().equals(application)) + ! nodeOnHost.allocation().get().owner().tenant().equals(tenant)) return false; } return true; } - private boolean hostHasOnly(ApplicationId application, Optional<String> parentHostname) { + private boolean hostHasOnly(TenantName tenant, Optional<String> parentHostname) { if ( ! parentHostname.isPresent()) return true; // yes, as host is exclusive for (Node nodeOnHost : nodeRepository.getChildNodes(parentHostname.get())) { if ( ! nodeOnHost.allocation().isPresent()) continue; - if ( ! nodeOnHost.allocation().get().owner().equals(application)) + if ( ! nodeOnHost.allocation().get().owner().tenant().equals(application.tenant())) return false; } return true; diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DockerProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DockerProvisioningTest.java index 346c3155457..e1b1d74c6d0 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DockerProvisioningTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DockerProvisioningTest.java @@ -3,10 +3,12 @@ package com.yahoo.vespa.hosted.provision.provisioning; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.Capacity; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostSpec; +import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.Zone; import com.yahoo.vespa.hosted.provision.Node; @@ -168,12 +170,9 @@ public class DockerProvisioningTest { e.getMessage()); } - // Adding 3 nodes of another cluster for the same application works: - Set<HostSpec> hosts = new HashSet<>(tester.prepare(application1, - ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("myContainer2"), Version.fromString("6.39"), false), - Capacity.fromNodeCount(3, Optional.of(dockerFlavor), false), - 1)); - tester.activate(application1, hosts); + // Adding 3 nodes of another application for the same tenant works + ApplicationId application3 = ApplicationId.from(application1.tenant(), ApplicationName.from("app3"), InstanceName.from("default")); + prepareAndActivate(application3, 2, true, tester); } // In dev, test and staging you get nodes with default flavor, but we should get specified flavor for docker nodes |