diff options
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java index 839b60ca612..b019ca5a99c 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java @@ -404,10 +404,18 @@ public class NodeRepository extends AbstractComponent { } private Node move(Node node, Node.State toState, Optional<String> reason) { - if (toState == Node.State.active && !node.allocation().isPresent()) { + if (toState == Node.State.active && ! node.allocation().isPresent()) throw new IllegalArgumentException("Could not set " + node.hostname() + " active. It has no allocation."); - } + try (Mutex lock = lock(node)) { + if (toState == Node.State.active) { + for (Node currentActive : getNodes(node.allocation().get().owner(), Node.State.active)) { + if (node.allocation().get().membership().cluster().equals(currentActive.allocation().get().membership().cluster()) + && node.allocation().get().membership().index() == currentActive.allocation().get().membership().index()) + throw new IllegalArgumentException("Could not move " + node + " to active:" + + "It has the same cluster and index as an existing node"); + } + } return zkClient.writeTo(toState, node, reason); } } |