summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-11-18 13:15:09 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2019-11-18 13:15:09 +0100
commit2d07304049b00d679403b143adee7b481b099bb8 (patch)
treeda3a7aeaab67e9a6023ef1d94a6aada0995674c9 /node-repository
parent6712756a8fb865230721ce5a14db7f851ef23096 (diff)
Choose cheaper nodes with less skew regardless of parent host state
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/PrioritizableNode.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/PrioritizableNode.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/PrioritizableNode.java
index 1f45e466c9d..46932eb1468 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/PrioritizableNode.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/PrioritizableNode.java
@@ -79,11 +79,6 @@ class PrioritizableNode implements Comparable<PrioritizableNode> {
if (this.node.state() != other.node.state())
throw new IllegalStateException("Nodes " + this.node + " and " + other.node + " have different states");
- // Choose nodes where host is in more desirable state
- int thisHostStatePri = this.parent.map(host -> ALLOCATABLE_HOST_STATES.indexOf(host.state())).orElse(-2);
- int otherHostStatePri = other.parent.map(host -> ALLOCATABLE_HOST_STATES.indexOf(host.state())).orElse(-2);
- if (thisHostStatePri != otherHostStatePri) return otherHostStatePri - thisHostStatePri;
-
if (this.parent.isPresent() && other.parent.isPresent()) {
int diskCostDifference = NodeResources.DiskSpeed.compare(this.parent.get().flavor().resources().diskSpeed(),
other.parent.get().flavor().resources().diskSpeed());
@@ -104,6 +99,11 @@ class PrioritizableNode implements Comparable<PrioritizableNode> {
if (this.node.flavor().cost() < other.node.flavor().cost()) return -1;
if (other.node.flavor().cost() < this.node.flavor().cost()) return 1;
+ // Choose nodes where host is in more desirable state
+ int thisHostStatePri = this.parent.map(host -> ALLOCATABLE_HOST_STATES.indexOf(host.state())).orElse(-2);
+ int otherHostStatePri = other.parent.map(host -> ALLOCATABLE_HOST_STATES.indexOf(host.state())).orElse(-2);
+ if (thisHostStatePri != otherHostStatePri) return otherHostStatePri - thisHostStatePri;
+
// All else equal choose hostname alphabetically
return this.node.hostname().compareTo(other.node.hostname());
}