diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-03-19 10:49:54 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-03-19 11:16:59 +0100 |
commit | 0f20f06d090212293dfb13b438121dab6ec4ebf7 (patch) | |
tree | c14bb5662da84bb30cf346caf57f57eab976c53e /node-repository | |
parent | daf28d29a5147579fe3b3e7910070f543387f61e (diff) |
Require primary IP addresses for ready hosts
Diffstat (limited to 'node-repository')
4 files changed, 9 insertions, 4 deletions
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 67b32b139a3..4d0617c02fd 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 @@ -102,6 +102,11 @@ public final class Node implements Nodelike { if (switchHostname.isPresent()) throw new IllegalArgumentException("A child node cannot have switch hostname set"); } + if (type.isHost() && state == State.ready) { + requireNonEmpty(ipConfig.primary(), "A " + type + " must have at least one primary IP address in state " + state); + if (type == NodeType.host) requireNonEmpty(ipConfig.pool().asSet(), "A " + type + " must have a non-empty IP address pool in state " + state); + } + if (type != NodeType.host && reservedTo.isPresent()) throw new IllegalArgumentException("Only tenant hosts can be reserved to a tenant"); diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java index 0ba1a62777e..cb9fb8182d4 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java @@ -163,8 +163,6 @@ public class Nodes { .map(node -> { if (node.state() != Node.State.provisioned && node.state() != Node.State.dirty) illegal("Can not set " + node + " ready. It is not provisioned or dirty."); - if (node.type() == NodeType.host && node.ipConfig().pool().asSet().isEmpty()) - illegal("Can not set host " + node + " ready. Its IP address pool is empty."); return node.withWantToRetire(false, false, Agent.system, clock.instant()); }) .collect(Collectors.toList()); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClientTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClientTest.java index 11df26e4da6..f47fb7f23be 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClientTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClientTest.java @@ -29,7 +29,7 @@ public class CuratorDatabaseClientTest { @Test public void can_read_stored_host_information() throws Exception { - String zkline = "{\"hostname\":\"host1\",\"ipAddresses\":[\"127.0.0.1\"],\"openStackId\":\"7951bb9d-3989-4a60-a21c-13690637c8ea\",\"flavor\":\"default\",\"created\":1421054425159, \"type\":\"host\"}"; + String zkline = "{\"hostname\":\"host1\",\"ipAddresses\":[\"127.0.0.1\"],\"additionalIpAddresses\":[\"127.0.0.2\"],\"openStackId\":\"7951bb9d-3989-4a60-a21c-13690637c8ea\",\"flavor\":\"default\",\"created\":1421054425159, \"type\":\"host\"}"; curator.framework().create().creatingParentsIfNeeded().forPath("/provision/v1/ready/host1", zkline.getBytes()); List<Node> allocatedNodes = zkClient.readNodes(Node.State.ready); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java index 8aa362aa932..e94733967b7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java @@ -5,6 +5,7 @@ import com.yahoo.config.provision.Flavor; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.NodeType; import com.yahoo.vespa.hosted.provision.Node; +import com.yahoo.vespa.hosted.provision.node.IP; import org.junit.Test; import java.util.ArrayList; @@ -145,7 +146,8 @@ public class NodeCandidateTest { .parentHostname(hostname + "parent") .ipConfigWithEmptyPool(Set.of("::1")).build(); Node parent = Node.create(hostname + "parent", hostname, new Flavor(totalHostResources), Node.State.ready, NodeType.host) - .ipConfigWithEmptyPool(Set.of("::1")).build(); + .ipConfig(new IP.Config(Set.of("::1"), Set.of("::2"))) + .build(); return new NodeCandidate.ConcreteNodeCandidate(node, totalHostResources.subtract(allocatedHostResources), Optional.of(parent), false, exclusiveSwitch, false, true, false); } |