diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-11-07 12:15:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 12:15:56 +0100 |
commit | 6a9b423bd2bc635ed84ab9589426954d930c78f6 (patch) | |
tree | e81bca87ff527243bce4b649cc6641897d2e8c17 /node-repository | |
parent | 610a597539f1d7e778c7060b7d282b3cbe711922 (diff) | |
parent | d163fe33bd1d14198db372fe87683004b02f52ea (diff) |
Merge pull request #24757 from vespa-engine/freva/set-account-on-node
Set cloud account on child nodes as well
Diffstat (limited to 'node-repository')
4 files changed, 19 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 768036fd284..de1f9e65415 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 @@ -118,7 +118,6 @@ public final class Node implements Nodelike { if (!ipConfig.pool().ipSet().isEmpty()) throw new IllegalArgumentException("A child node cannot have an IP address pool"); if (modelName.isPresent()) throw new IllegalArgumentException("A child node cannot have model name set"); if (switchHostname.isPresent()) throw new IllegalArgumentException("A child node cannot have switch hostname set"); - if (!cloudAccount.isEmpty()) throw new IllegalArgumentException("A child node cannot have cloud account set"); } if (type != NodeType.host && reservedTo.isPresent()) diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java index 7947fe9f021..c2a6e4658f3 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.provision.provisioning; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationTransaction; +import com.yahoo.config.provision.CloudAccount; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Flavor; @@ -88,7 +89,8 @@ class Activator { NodeList activeToRemove = oldActive.matching(node -> ! hostnames.contains(node.hostname())); remove(activeToRemove, transaction); // TODO: Pass activation time in this call and next line - nodeRepository.nodes().activate(newActive.asList(), transaction.nested()); // activate also continued active to update node state + // TODO (freva): Replace .mapToList(...) with .asList() after 8.80 + nodeRepository.nodes().activate(newActive.mapToList(node -> fixCloudAccount(node, allNodes)), transaction.nested()); // activate also continued active to update node state rememberResourceChange(transaction, generation, activationTime, oldActive.not().retired(), @@ -248,4 +250,14 @@ class Activator { return null; } + private Node fixCloudAccount(Node node, NodeList allNodes) { + // Existing nodes do not have cloudAccount set, copy the one from parent + CloudAccount cloudAccount = allNodes.parentOf(node).map(Node::cloudAccount).orElseGet(node::cloudAccount); + return new Node(node.id(), node.ipConfig(), node.hostname(), + node.parentHostname(), node.flavor(), node.status(), node.state(), node.allocation(), node.history(), + node.type(), node.reports(), node.modelName(), node.reservedTo(), + node.exclusiveToApplicationId(), node.exclusiveToClusterType(), node.switchHostname(), + node.trustedCertificates(), cloudAccount); + } + } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java index 8e13ac65c21..b1b230479ee 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java @@ -430,7 +430,9 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat resources.with(parent.get().resources().diskSpeed()) .with(parent.get().resources().storageType()) .with(parent.get().resources().architecture()), - NodeType.tenant).build(); + NodeType.tenant) + .cloudAccount(parent.get().cloudAccount()) + .build(); return new ConcreteNodeCandidate(node, freeParentCapacity, parent, violatesSpares, exclusiveSwitch, isSurplus, isNew, isResizable); } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java index 35b80459168..15a6b6ba523 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java @@ -74,7 +74,9 @@ public class ProvisionedHost { /** Generate {@link Node} instance representing the node running on this physical host */ public Node generateNode() { - return Node.reserve(Set.of(), nodeHostname(), hostHostname, nodeResources, hostType.childNodeType()).build(); + return Node.reserve(Set.of(), nodeHostname(), hostHostname, nodeResources, hostType.childNodeType()) + .cloudAccount(cloudAccount) + .build(); } public String getId() { return id; } |