diff options
author | Martin Polden <mpolden@mpolden.no> | 2018-12-18 11:37:30 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2019-01-02 09:52:06 +0100 |
commit | fd8a127ca3aa050aad7b55ebe17a3c656f09871a (patch) | |
tree | 17303557daf889700f4e97934fdfe00cb3e5a588 | |
parent | 0270ccff73718d7786aae5aa7bdb0e3eb653e7c2 (diff) |
Rename field openStackId -> id
12 files changed, 47 insertions, 44 deletions
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java index 48e85f6047e..735de107b32 100644 --- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java +++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java @@ -63,8 +63,7 @@ public class IdentityDocumentGeneratorTest { Optional.empty(), new MockNodeFlavors().getFlavorOrThrow("default"), NodeType.host); - Node containerNode = Node.createDockerNode("docker-1", - ImmutableSet.of("::1"), + Node containerNode = Node.createDockerNode(ImmutableSet.of("::1"), new HashSet<>(), containerHostname, Optional.of(parentHostname), diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/instanceconfirmation/InstanceValidatorTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/instanceconfirmation/InstanceValidatorTest.java index bb70a5981b8..d9346369462 100644 --- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/instanceconfirmation/InstanceValidatorTest.java +++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/instanceconfirmation/InstanceValidatorTest.java @@ -226,7 +226,7 @@ public class InstanceValidatorTest { } private List<Node> allocateNode(List<Node> nodeList, Node node, ApplicationId applicationId) { - nodeList.removeIf(n -> n.openStackId().equals(node.openStackId())); + nodeList.removeIf(n -> n.id().equals(node.id())); nodeList.add(node.allocate(applicationId, ClusterMembership.from("container/default/0/0", Version.fromString("6.123.4")), Instant.now())); return nodeList; } 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 85808aa7775..542ffb0ba95 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 @@ -32,7 +32,7 @@ public final class Node { private final Set<String> ipAddresses; private final IP.AddressPool ipAddressPool; private final String hostname; - private final String openStackId; + private final String id; private final Optional<String> parentHostname; private final Flavor flavor; private final Status status; @@ -46,27 +46,27 @@ public final class Node { private Optional<Allocation> allocation; /** Temporary method until we can merge it with the other create method */ - public static Node createDockerNode(String openStackId, Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname, Flavor flavor, NodeType type) { - return new Node(openStackId, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, Status.initial(), State.reserved, - Optional.empty(), History.empty(), type); + public static Node createDockerNode(Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname, Flavor flavor, NodeType type) { + return new Node("fake-" + hostname, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, Status.initial(), State.reserved, + Optional.empty(), History.empty(), type); } /** Creates a node in the initial state (reserved for docker containers, provisioned otherwise) */ public static Node create(String openStackId, Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname, Flavor flavor, NodeType type) { return new Node(openStackId, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, Status.initial(), State.provisioned, - Optional.empty(), History.empty(), type); + Optional.empty(), History.empty(), type); } /** Do not use. Construct nodes by calling {@link NodeRepository#createNode} */ - private Node(String openStackId, Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname, + private Node(String id, Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname, Flavor flavor, Status status, State state, Allocation allocation, History history, NodeType type) { - this(openStackId, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, status, state, Optional.of(allocation), history, type); + this(id, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, status, state, Optional.of(allocation), history, type); } - public Node(String openStackId, Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname, + public Node(String id, Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname, Flavor flavor, Status status, State state, Optional<Allocation> allocation, History history, NodeType type) { - Objects.requireNonNull(openStackId, "A node must have an openstack id"); + Objects.requireNonNull(id, "A node must have an ID"); requireIpAddresses(ipAddresses, "A node must have at least one valid IP address"); requireNonEmptyString(hostname, "A node must have a hostname"); requireNonEmptyString(parentHostname, "A parent host name must be a proper value"); @@ -81,7 +81,7 @@ public final class Node { this.ipAddressPool = new IP.AddressPool(this, ipAddressPool); this.hostname = hostname; this.parentHostname = parentHostname; - this.openStackId = openStackId; + this.id = id; this.flavor = flavor; this.status = status; this.state = state; @@ -100,9 +100,17 @@ public final class Node { /** Returns the host name of this node */ public String hostname() { return hostname; } - // TODO: Different meaning for vms and docker hosts? - /** Returns the OpenStack id of this node, or of its docker host if this is a virtual node */ - public String openStackId() { return openStackId; } + /** + * Unique identifier for this node. Code should not depend on this as its main purpose is to aid human operators in + * mapping a node to the corresponding cloud instance. No particular format is enforced. + * + * Formats used vary between the underlying cloud providers: + * + * - OpenStack: UUID + * - AWS: Instance ID + * - Docker containers: fake-[hostname] + */ + public String id() { return id; } /** Returns the parent hostname for this node if this node is a docker container or a VM (i.e. it has a parent host). Otherwise, empty **/ public Optional<String> parentHostname() { return parentHostname; } @@ -159,22 +167,22 @@ public final class Node { /** Returns a node with the status assigned to the given value */ public Node with(Status status) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); } /** Returns a node with the type assigned to the given value */ public Node with(NodeType type) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); } /** Returns a node with the flavor assigned to the given value */ public Node with(Flavor flavor) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); } /** Returns a copy of this with the reboot generation set to generation */ public Node withReboot(Generation generation) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status.withReboot(generation), state, + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status.withReboot(generation), state, allocation, history, type); } @@ -204,24 +212,24 @@ public final class Node { * Do not use this to allocate a node. */ public Node with(Allocation allocation) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); } /** Returns a copy of this node with the IP addresses set to the given value. */ public Node withIpAddresses(Set<String> ipAddresses) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); } /** Returns a copy of this node with IP address pool set to the given value. */ public Node withIpAddressPool(Set<String> ipAddressPool) { - return new Node(openStackId, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, status, state, + return new Node(id, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, status, state, allocation, history, type); } /** Returns a copy of this node with the parent hostname assigned to the given value. */ public Node withParentHostname(String parentHostname) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, Optional.of(parentHostname), flavor, status, state, + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, Optional.of(parentHostname), flavor, status, state, allocation, history, type); } @@ -236,7 +244,7 @@ public final class Node { /** Returns a copy of this node with the given history. */ public Node with(History history) { - return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); + return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type); } private static void requireNonEmptyString(Optional<String> value, String message) { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java index 9bcfdd8b494..c99cccd2ab9 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java @@ -211,7 +211,7 @@ public class CuratorDatabaseClient { CuratorTransaction curatorTransaction = newCuratorTransactionIn(transaction); for (Node node : nodes) { - Node newNode = new Node(node.openStackId(), node.ipAddresses(), node.ipAddressPool().asSet(), node.hostname(), + Node newNode = new Node(node.id(), node.ipAddresses(), node.ipAddressPool().asSet(), node.hostname(), node.parentHostname(), node.flavor(), newNodeStatus(node, toState), toState, diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java index 61425080680..1333b61cb16 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java @@ -45,7 +45,7 @@ public class NodeSerializer { private static final String hostnameKey = "hostname"; private static final String ipAddressesKey = "ipAddresses"; private static final String ipAddressPoolKey = "additionalIpAddresses"; - private static final String openStackIdKey = "openStackId"; + private static final String idKey = "openStackId"; private static final String parentHostnameKey = "parentHostname"; private static final String historyKey = "history"; private static final String instanceKey = "instance"; // legacy name, TODO: change to allocation with backwards compat @@ -100,7 +100,7 @@ public class NodeSerializer { object.setString(hostnameKey, node.hostname()); toSlime(node.ipAddresses(), object.setArray(ipAddressesKey)); toSlime(node.ipAddressPool().asSet(), object.setArray(ipAddressPoolKey)); - object.setString(openStackIdKey, node.openStackId()); + object.setString(idKey, node.id()); node.parentHostname().ifPresent(hostname -> object.setString(parentHostnameKey, hostname)); object.setString(flavorKey, node.flavor().name()); object.setLong(rebootGenerationKey, node.status().reboot().wanted()); @@ -151,7 +151,7 @@ public class NodeSerializer { } private Node nodeFromSlime(Node.State state, Inspector object) { - return new Node(object.field(openStackIdKey).asString(), + return new Node(object.field(idKey).asString(), ipAddressesFromSlime(object, ipAddressesKey), ipAddressesFromSlime(object, ipAddressPoolKey), object.field(hostnameKey).asString(), diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java index 6624a3c8b59..584df1c7649 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java @@ -143,8 +143,7 @@ public class NodePrioritizer { continue; } - Node newNode = Node.createDockerNode("fake-" + allocation.get().hostname(), - allocation.get().addresses(), + Node newNode = Node.createDockerNode(allocation.get().addresses(), Collections.emptySet(), allocation.get().hostname(), Optional.of(node.hostname()), diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java index 5c0f0447cac..733f5df7858 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java @@ -142,7 +142,7 @@ class NodesResponse extends HttpResponse { if (node.parentHostname().isPresent()) { object.setString("parentHostname", node.parentHostname().get()); } - object.setString("openStackId", node.openStackId()); + object.setString("openStackId", node.id()); object.setString("flavor", node.flavor().name()); object.setString("canonicalFlavor", node.flavor().canonicalName()); object.setDouble("minDiskAvailableGb", node.flavor().getMinDiskAvailableGb()); diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifier.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifier.java index 0891279f30c..a434f021cad 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifier.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifier.java @@ -85,15 +85,15 @@ class NodeIdentifier { } private String getHostFromCalypsoCertificate(List<SubjectAlternativeName> sans) { - String openstackId = getUniqueInstanceId(sans); + String openStackId = getUniqueInstanceId(sans); return nodeCache.get().stream() - .filter(node -> node.openStackId().equals(openstackId)) + .filter(node -> node.id().equals(openStackId)) .map(Node::hostname) .findFirst() .orElseThrow(() -> new NodeIdentifierException( String.format( "Cannot find node with openstack-id '%s' in node repository (SANs=%s)", - openstackId, + openStackId, sans.stream().map(SubjectAlternativeName::getValue).collect(Collectors.joining(",", "[", "]"))))); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java index 1d673a2224a..0911d3301a6 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java @@ -127,11 +127,11 @@ public class MetricsReporterTest { nodeRepository.dirtyRecursively("dockerHost", Agent.system, getClass().getSimpleName()); nodeRepository.setReady("dockerHost", Agent.system, getClass().getSimpleName()); - Node container1 = Node.createDockerNode("openStackId1:1", Collections.singleton("::2"), Collections.emptySet(), "container1", Optional.of("dockerHost"), nodeFlavors.getFlavorOrThrow("docker"), NodeType.tenant); + Node container1 = Node.createDockerNode(Collections.singleton("::2"), Collections.emptySet(), "container1", Optional.of("dockerHost"), nodeFlavors.getFlavorOrThrow("docker"), NodeType.tenant); container1 = container1.with(allocation(Optional.of("app1")).get()); nodeRepository.addDockerNodes(Collections.singletonList(container1)); - Node container2 = Node.createDockerNode("openStackId1:2", Collections.singleton("::3"), Collections.emptySet(), "container2", Optional.of("dockerHost"), nodeFlavors.getFlavorOrThrow("docker2"), NodeType.tenant); + Node container2 = Node.createDockerNode(Collections.singleton("::3"), Collections.emptySet(), "container2", Optional.of("dockerHost"), nodeFlavors.getFlavorOrThrow("docker2"), NodeType.tenant); container2 = container2.with(allocation(Optional.of("app2")).get()); nodeRepository.addDockerNodes(Collections.singletonList(container2)); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java index 2a311405499..5804add3fc0 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java @@ -50,7 +50,7 @@ public class SerializationTest { Node copy = nodeSerializer.fromJson(Node.State.provisioned, nodeSerializer.toJson(node)); assertEquals(node.hostname(), copy.hostname()); - assertEquals(node.openStackId(), copy.openStackId()); + assertEquals(node.id(), copy.id()); assertEquals(node.state(), copy.state()); assertFalse(copy.allocation().isPresent()); assertEquals(0, copy.history().events().size()); @@ -77,7 +77,7 @@ public class SerializationTest { node = node.with(NodeType.tenant); Node copy = nodeSerializer.fromJson(Node.State.provisioned, nodeSerializer.toJson(node)); - assertEquals(node.openStackId(), copy.openStackId()); + assertEquals(node.id(), copy.id()); assertEquals(node.hostname(), copy.hostname()); assertEquals(node.state(), copy.state()); assertEquals(1, copy.allocation().get().restartGeneration().wanted()); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizerTest.java index 6e07585afd4..f278f2a1fba 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizerTest.java @@ -68,8 +68,8 @@ public class NodePrioritizerTest { } private static Node createNode(Node parent, String hostname, String flavor) { - return Node.createDockerNode("openid", Collections.singleton("127.0.0.1"), new HashSet<>(), hostname, Optional.of(parent.hostname()), - flavors.getFlavorOrThrow(flavor), NodeType.tenant); + return Node.createDockerNode(Collections.singleton("127.0.0.1"), new HashSet<>(), hostname, Optional.of(parent.hostname()), + flavors.getFlavorOrThrow(flavor), NodeType.tenant); } private static Node createParent(String hostname) { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifierTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifierTest.java index 80eec6c3d30..2412368b968 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifierTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/filter/NodeIdentifierTest.java @@ -36,8 +36,6 @@ import java.util.Optional; import static com.yahoo.security.KeyAlgorithm.EC; import static com.yahoo.security.SignatureAlgorithm.SHA256_WITH_ECDSA; import static com.yahoo.vespa.athenz.identityprovider.api.IdentityType.*; -import static com.yahoo.security.KeyAlgorithm.RSA; -import static com.yahoo.security.SignatureAlgorithm.SHA256_WITH_RSA; import static com.yahoo.vespa.hosted.provision.restapi.v2.filter.NodeIdentifier.CONFIGSERVER_HOST_IDENTITY; import static com.yahoo.vespa.hosted.provision.restapi.v2.filter.NodeIdentifier.PROXY_HOST_IDENTITY; import static com.yahoo.vespa.hosted.provision.restapi.v2.filter.NodeIdentifier.TENANT_DOCKER_CONTAINER_IDENTITY; @@ -231,7 +229,6 @@ public class NodeIdentifierTest { private static Node createNode(String clusterId, int clusterIndex, String tenant, String application) { return Node .createDockerNode( - OPENSTACK_ID, singleton("1.2.3.4"), emptySet(), HOSTNAME, |