diff options
author | Martin Polden <mpolden@mpolden.no> | 2019-04-24 12:58:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-24 12:58:38 +0200 |
commit | 18dee72da547cd6424eee04c33c1953e5b2d132e (patch) | |
tree | 45364bfaa06b1c84d54064cbd4e10af48f813f9b /node-repository | |
parent | 341a8d2b09937c2c713c3db724457656977fe671 (diff) | |
parent | b7cd339056254d6a57324cdfa587106248de1a49 (diff) |
Merge pull request #9162 from vespa-engine/mpolden/remove-lb-feature-flag
Remove feature flag guard for exclusive load balancers
Diffstat (limited to 'node-repository')
26 files changed, 241 insertions, 589 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 999eae73475..ccdfbf0b402 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 @@ -15,7 +15,6 @@ import com.yahoo.config.provisioning.NodeRepositoryConfig; import com.yahoo.transaction.Mutex; import com.yahoo.transaction.NestedTransaction; import com.yahoo.vespa.curator.Curator; -import com.yahoo.vespa.hosted.provision.flag.Flags; import com.yahoo.vespa.hosted.provision.lb.LoadBalancer; import com.yahoo.vespa.hosted.provision.lb.LoadBalancerInstance; import com.yahoo.vespa.hosted.provision.lb.LoadBalancerList; @@ -87,7 +86,6 @@ public class NodeRepository extends AbstractComponent { private final OsVersions osVersions; private final FirmwareChecks firmwareChecks; private final DockerImages dockerImages; - private final Flags flags; /** * Creates a node repository from a zookeeper provider. @@ -112,7 +110,6 @@ public class NodeRepository extends AbstractComponent { this.osVersions = new OsVersions(this.db); this.firmwareChecks = new FirmwareChecks(db, clock); this.dockerImages = new DockerImages(db, dockerImage); - this.flags = new Flags(this.db); // read and write all nodes to make sure they are stored in the latest version of the serialized format for (Node.State state : Node.State.values()) @@ -137,11 +134,6 @@ public class NodeRepository extends AbstractComponent { /** Returns the docker images to use for nodes in this. */ public DockerImages dockerImages() { return dockerImages; } - /** Returns feature flags of this node repository */ - public Flags flags() { - return flags; - } - // ---------------- Query API ---------------------------------------------------------------- /** diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/Flag.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/Flag.java deleted file mode 100644 index a22e1dea024..00000000000 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/Flag.java +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.provision.flag; - -import com.google.common.collect.ImmutableSet; -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Objects; -import java.util.Set; - -/** - * Represents a feature flag and its status. Use {@link Flags#get(FlagId)} to lookup status for a specific flag. - * - * @author mpolden - */ -public class Flag { - - private final FlagId id; - private final boolean enabled; - private final Set<String> hostnames; - private final Set<ApplicationId> applications; - - public Flag(FlagId id, boolean enabled, Set<String> hostnames, Set<ApplicationId> applications) { - this.id = Objects.requireNonNull(id, "id must be non-null"); - this.enabled = enabled; - this.hostnames = ImmutableSet.copyOf(Objects.requireNonNull(hostnames, "hostnames must be non-null")); - this.applications = ImmutableSet.copyOf(Objects.requireNonNull(applications, "applications must be non-null")); - } - - public FlagId id() { - return id; - } - - /** The hostnames this flag should apply to */ - public Set<String> hostnames() { - return hostnames; - } - - /** The applications this flag should apply to */ - public Set<ApplicationId> applications() { - return applications; - } - - /** - * Returns whether this flag is enabled for all dimensions. Note: More specific dimensions always return true when - * this is true - */ - public boolean isEnabled() { - return enabled; - } - - /** Returns whether this flag is enabled for given hostname */ - public boolean isEnabled(HostName hostname) { - return enabled || hostnames.contains(hostname.value()); - } - - /** Returns whether this flag is enabled for given application */ - public boolean isEnabled(ApplicationId application) { - return enabled || applications.contains(application); - } - - /** Returns a copy of this with this flag enabled for all dimensions */ - public Flag withEnabled(boolean enabled) { - return new Flag(id, enabled, hostnames, applications); - } - - /** Returns a copy of this with enabled set for hostname */ - public Flag withEnabled(HostName hostname, boolean enabled) { - Set<String> hostnames = new LinkedHashSet<>(this.hostnames); - if (enabled) { - hostnames.add(hostname.value()); - } else { - hostnames.remove(hostname.value()); - } - return new Flag(id, this.enabled, hostnames, applications); - } - - /** Returns a copy of this with enabled set for application */ - public Flag withEnabled(ApplicationId application, boolean enabled) { - Set<ApplicationId> applications = new LinkedHashSet<>(this.applications); - if (enabled) { - applications.add(application); - } else { - applications.remove(application); - } - return new Flag(id, this.enabled, hostnames, applications); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Flag flag = (Flag) o; - return id == flag.id; - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - /** Create a flag for given feature that is disabled for all dimensions */ - public static Flag disabled(FlagId id) { - return new Flag(id, false, Collections.emptySet(), Collections.emptySet()); - } - -} diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/FlagId.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/FlagId.java deleted file mode 100644 index 1b798c14588..00000000000 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/FlagId.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.provision.flag; - -import java.util.Arrays; - -/** - * Features of this node repository that can be toggled. - * - * @author mpolden - */ -public enum FlagId { - - /** Indicates whether a exclusive load balancer should be provisioned */ - exclusiveLoadBalancer("exclusive-load-balancer"); - - private final String serializedValue; - - FlagId(String serializedValue) { - this.serializedValue = serializedValue; - } - - public String serializedValue() { - return serializedValue; - } - - public static FlagId fromSerializedForm(String value) { - return Arrays.stream(FlagId.values()) - .filter(f -> f.serializedValue().equals(value)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("Could not find flag ID by serialized value '" + - value + "'")); - } - -} diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/Flags.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/Flags.java deleted file mode 100644 index b4ecf415ede..00000000000 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/Flags.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.provision.flag; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; -import com.yahoo.vespa.curator.Lock; -import com.yahoo.vespa.hosted.provision.NodeRepository; -import com.yahoo.vespa.hosted.provision.persistence.CuratorDatabaseClient; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * This class provides feature flags for the node repository. A feature flag can be toggled for the following - * dimensions: - * - * 1) The node repository (entire zone) - * 2) A specific node - * 3) A specific application - * - * Code which needs to consider feature flags can access them through {@link NodeRepository#flags()}. - * - * @author mpolden - */ -public class Flags { - - private final CuratorDatabaseClient db; - - public Flags(CuratorDatabaseClient db) { - this.db = Objects.requireNonNull(db, "db must be non-null"); - } - - /** Get status for given feature flag */ - public Flag get(FlagId id) { - return db.readFlag(id).orElseGet(() -> Flag.disabled(id)); - } - - /** Get all known feature flags */ - public List<Flag> list() { - return Arrays.stream(FlagId.values()) - .map(this::get) - .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); - } - - /** Enable feature flag in this node repository */ - public void setEnabled(FlagId flag, boolean enabled) { - write(flag, (f) -> f.withEnabled(enabled)); - } - - /** Enable feature flag for given application */ - public void setEnabled(FlagId flag, ApplicationId application, boolean enabled) { - write(flag, (f) -> f.withEnabled(application, enabled)); - } - - /** Enable feature flag for given node */ - public void setEnabled(FlagId flag, HostName hostname, boolean enabled) { - write(flag, (f) -> f.withEnabled(hostname, enabled)); - } - - private void write(FlagId id, Function<Flag, Flag> updateFunc) { - try (Lock lock = db.lockFlags()) { - db.writeFlag(updateFunc.apply(get(id))); - } - } - -} 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 3ed8ef9f64a..a78c48418ea 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 @@ -20,8 +20,6 @@ import com.yahoo.vespa.curator.recipes.CuratorCounter; import com.yahoo.vespa.curator.transaction.CuratorOperations; import com.yahoo.vespa.curator.transaction.CuratorTransaction; import com.yahoo.vespa.hosted.provision.Node; -import com.yahoo.vespa.hosted.provision.flag.Flag; -import com.yahoo.vespa.hosted.provision.flag.FlagId; import com.yahoo.vespa.hosted.provision.lb.LoadBalancer; import com.yahoo.vespa.hosted.provision.lb.LoadBalancerId; import com.yahoo.vespa.hosted.provision.node.Agent; @@ -77,6 +75,7 @@ public class CuratorDatabaseClient { public CuratorDatabaseClient(NodeFlavors flavors, Curator curator, Clock clock, Zone zone, boolean useCache) { this.nodeSerializer = new NodeSerializer(flavors); this.zone = zone; + curator.delete(flagsRoot); // TODO: Remove after 7.42 has been released this.curatorDatabase = new CuratorDatabase(curator, root, useCache); this.clock = clock; this.provisionIndexCounter = new CuratorCounter(curator, root.append("provisionIndexCounter").getAbsolute()); @@ -97,7 +96,6 @@ public class CuratorDatabaseClient { curatorDatabase.create(dockerImagesPath()); curatorDatabase.create(firmwareCheckPath()); curatorDatabase.create(loadBalancersRoot); - curatorDatabase.create(flagsRoot); provisionIndexCounter.initialize(100); } @@ -527,28 +525,6 @@ public class CuratorDatabaseClient { return loadBalancersRoot.append(id.serializedForm()); } - public void writeFlag(Flag flag) { - Path path = flagPath(flag.id()); - NestedTransaction transaction = new NestedTransaction(); - CuratorTransaction curatorTransaction = curatorDatabase.newCuratorTransactionIn(transaction); - curatorTransaction.add(createOrSet(path, FlagSerializer.toJson(flag))); - transaction.commit(); - } - - - // Flags - public Optional<Flag> readFlag(FlagId id) { - return read(flagPath(id), FlagSerializer::fromJson); - } - - public Lock lockFlags() { - return lock(lockRoot.append("flagsLock"), defaultLockTimeout); - } - - private Path flagPath(FlagId id) { - return flagsRoot.append(id.serializedValue()); - } - private Transaction.Operation createOrSet(Path path, byte[] data) { if (curatorDatabase.exists(path)) { return CuratorOperations.setData(path.getAbsolute(), data); diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/FlagSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/FlagSerializer.java deleted file mode 100644 index 431aa92a513..00000000000 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/FlagSerializer.java +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.provision.persistence; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.slime.ArrayTraverser; -import com.yahoo.slime.Cursor; -import com.yahoo.slime.Inspector; -import com.yahoo.slime.Slime; -import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.provision.flag.Flag; -import com.yahoo.vespa.hosted.provision.flag.FlagId; - -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * @author mpolden - */ -public class FlagSerializer { - - private static final String featureField = "feature"; - private static final String enabledField = "enabled"; - private static final String hostnamesField = "hostnames"; - private static final String applicationsField = "applications"; - - public static byte[] toJson(Flag flag) { - Slime slime = new Slime(); - Cursor root = slime.setObject(); - - root.setString(featureField, flag.id().serializedValue()); - root.setBool(enabledField, flag.isEnabled()); - - Cursor nodeArray = root.setArray(hostnamesField); - flag.hostnames().forEach(nodeArray::addString); - - Cursor applicationArray = root.setArray(applicationsField); - flag.applications().forEach(application -> applicationArray.addString(application.serializedForm())); - - try { - return SlimeUtils.toJsonBytes(slime); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - public static Flag fromJson(byte[] data) { - Inspector inspect = SlimeUtils.jsonToSlime(data).get(); - - Set<String> hostnames = new LinkedHashSet<>(); - inspect.field(hostnamesField).traverse((ArrayTraverser) (i, hostname) -> hostnames.add(hostname.asString())); - - Set<ApplicationId> applications = new LinkedHashSet<>(); - inspect.field(applicationsField).traverse((ArrayTraverser) (i, application) -> { - applications.add(ApplicationId.fromSerializedForm(application.asString())); - }); - - return new Flag(FlagId.fromSerializedForm(inspect.field(featureField).asString()), - inspect.field(enabledField).asBool(), - hostnames, - applications); - } - -} diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisioner.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisioner.java index 629bbf56884..f5f8ed53d2a 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisioner.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisioner.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.provision.provisioning; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostName; +import com.yahoo.config.provision.NodeType; import com.yahoo.transaction.Mutex; import com.yahoo.transaction.NestedTransaction; import com.yahoo.vespa.hosted.provision.Node; @@ -93,7 +94,7 @@ public class LoadBalancerProvisioner { /** Returns a list of active containers for given application, grouped by cluster spec */ private Map<ClusterSpec, List<Node>> activeContainers(ApplicationId application) { - return new NodeList(nodeRepository.getNodes(Node.State.active)) + return new NodeList(nodeRepository.getNodes(NodeType.tenant, Node.State.active)) .owner(application) .filter(node -> node.state().isAllocated()) .type(ClusterSpec.Type.container) diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeRepositoryProvisioner.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeRepositoryProvisioner.java index 246c56ee28b..c91d28e17ce 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeRepositoryProvisioner.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeRepositoryProvisioner.java @@ -21,7 +21,6 @@ import com.yahoo.vespa.flags.FlagSource; import com.yahoo.vespa.flags.Flags; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; -import com.yahoo.vespa.hosted.provision.flag.FlagId; import com.yahoo.vespa.hosted.provision.node.Allocation; import com.yahoo.vespa.hosted.provision.node.filter.ApplicationFilter; import com.yahoo.vespa.hosted.provision.node.filter.NodeHostFilter; @@ -116,13 +115,11 @@ public class NodeRepositoryProvisioner implements Provisioner { validate(hosts); activator.activate(application, hosts, transaction); transaction.onCommitted(() -> { - if (nodeRepository.flags().get(FlagId.exclusiveLoadBalancer).isEnabled(application)) { - try { - loadBalancerProvisioner.ifPresent(lbProvisioner -> lbProvisioner.provision(application)); - } catch (Exception e) { - log.log(LogLevel.ERROR, "Failed to provision load balancer for application " + - application.toShortString(), e); - } + try { + loadBalancerProvisioner.ifPresent(lbProvisioner -> lbProvisioner.provision(application)); + } catch (Exception e) { + log.log(LogLevel.ERROR, "Failed to provision load balancer for application " + + application.toShortString(), e); } }); } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/FlagsResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/FlagsResponse.java deleted file mode 100644 index 1bc016bcda2..00000000000 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/FlagsResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.provision.restapi.v2; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.slime.Cursor; -import com.yahoo.slime.JsonFormat; -import com.yahoo.slime.Slime; -import com.yahoo.vespa.hosted.provision.flag.Flag; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -/** - * @author mpolden - */ -public class FlagsResponse extends HttpResponse { - - private final List<Flag> flags; - - public FlagsResponse(List<Flag> flags) { - super(200); - this.flags = flags; - } - - @Override - public void render(OutputStream out) throws IOException { - Slime slime = new Slime(); - Cursor root = slime.setObject(); - Cursor flagArray = root.setArray("flags"); - flags.forEach(flag -> { - Cursor flagObject = flagArray.addObject(); - flagObject.setString("id", flag.id().serializedValue()); - flagObject.setBool("enabled", flag.isEnabled()); - Cursor nodeArray = flagObject.setArray("enabledHostnames"); - flag.hostnames().forEach(nodeArray::addString); - Cursor applicationArray = flagObject.setArray("enabledApplications"); - flag.applications().stream() - .map(ApplicationId::serializedForm) - .forEach(applicationArray::addString); - }); - new JsonFormat(true).encode(out, slime); - } - - @Override - public String getContentType() { - return "application/json"; - } - -} diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java index 58125304d6f..a18b7ab72ad 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java @@ -2,10 +2,8 @@ package com.yahoo.vespa.hosted.provision.restapi.v2; import com.yahoo.component.Version; -import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.DockerImage; import com.yahoo.config.provision.HostFilter; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.NodeFlavors; import com.yahoo.config.provision.NodeType; import com.yahoo.container.jdisc.HttpRequest; @@ -20,7 +18,6 @@ import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.hosted.provision.NoSuchNodeException; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; -import com.yahoo.vespa.hosted.provision.flag.FlagId; import com.yahoo.vespa.hosted.provision.maintenance.NodeRepositoryMaintenance; import com.yahoo.vespa.hosted.provision.node.Agent; import com.yahoo.vespa.hosted.provision.node.filter.ApplicationFilter; @@ -108,7 +105,6 @@ public class NodesApiHandler extends LoggingRequestHandler { if (path.equals( "/nodes/v2/command/")) return ResourcesResponse.fromStrings(request.getUri(), "restart", "reboot"); if (path.equals( "/nodes/v2/maintenance/")) return new JobsResponse(maintenance.jobControl()); if (path.equals( "/nodes/v2/upgrade/")) return new UpgradeResponse(maintenance.infrastructureVersions(), nodeRepository.osVersions(), nodeRepository.dockerImages()); - if (path.equals( "/nodes/v2/flags/")) return new FlagsResponse(nodeRepository.flags().list()); throw new NotFoundException("Nothing at path '" + path + "'"); } @@ -169,8 +165,6 @@ public class NodesApiHandler extends LoggingRequestHandler { return new MessageResponse("Added " + addedNodes + " nodes to the provisioned state"); } if (path.matches("/nodes/v2/maintenance/inactive/{job}")) return setJobActive(path.get("job"), false); - if (path.matches("/nodes/v2/flags/{flag}")) return setFlag(path.get("flag"), true, "", ""); - if (path.matches("/nodes/v2/flags/{flag}/{dimension}/{value}")) return setFlag(path.get("flag"), true, path.get("dimension"), path.get("value")); if (path.matches("/nodes/v2/upgrade/firmware")) return requestFirmwareCheckResponse(); throw new NotFoundException("Nothing at path '" + request.getUri().getPath() + "'"); @@ -184,8 +178,6 @@ public class NodesApiHandler extends LoggingRequestHandler { return new MessageResponse("Removed " + removedNodes.stream().map(Node::hostname).collect(Collectors.joining(", "))); } if (path.matches("/nodes/v2/maintenance/inactive/{job}")) return setJobActive(path.get("job"), true); - if (path.matches("/nodes/v2/flags/{flag}")) return setFlag(path.get("flag"), false, "", ""); - if (path.matches("/nodes/v2/flags/{flag}/{dimension}/{value}")) return setFlag(path.get("flag"), false, path.get("dimension"), path.get("value")); if (path.matches("/nodes/v2/upgrade/firmware")) return cancelFirmwareCheckResponse(); throw new NotFoundException("Nothing at path '" + request.getUri().getPath() + "'"); @@ -283,24 +275,6 @@ public class NodesApiHandler extends LoggingRequestHandler { return new MessageResponse((active ? "Re-activated" : "Deactivated" ) + " job '" + jobName + "'"); } - private HttpResponse setFlag(String flag, boolean enabled, String dimension, String value) { - FlagId flagId = FlagId.fromSerializedForm(flag); - switch (dimension) { - case "application": - nodeRepository.flags().setEnabled(flagId, ApplicationId.fromSerializedForm(value), enabled); - break; - case "node": - nodeRepository.flags().setEnabled(flagId, HostName.from(value), enabled); - break; - case "": - nodeRepository.flags().setEnabled(flagId, enabled); - break; - default: throw new IllegalArgumentException("Unknown flag dimension '" + dimension + "'"); - } - return new MessageResponse((enabled ? "Enabled" : "Disabled") + " feature " + flagId + - (!value.isEmpty() ? " for " + dimension + " '" + value + "'" : "")); - } - private MessageResponse setTargetVersions(HttpRequest request) { NodeType nodeType = NodeType.valueOf(lastElement(request.getUri().getPath()).toLowerCase()); Inspector inspector = toSlime(request.getData()).get(); diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java index 83f5d6bf783..b9fb88e900e 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java @@ -20,7 +20,6 @@ import com.yahoo.vespa.curator.mock.MockCurator; import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; -import com.yahoo.vespa.hosted.provision.flag.FlagId; import com.yahoo.vespa.hosted.provision.node.Agent; import com.yahoo.vespa.hosted.provision.node.Status; import com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner; @@ -85,8 +84,10 @@ public class MockNodeRepository extends NodeRepository { nodes.add(createNode("node6", "host6.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant)); - nodes.add(createNode("node7", "host7.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant)); - // 8 and 9 are added by web service calls + Node node7 = createNode("node7", "host7.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant); + nodes.add(node7); + + // 8, 9, 11 and 12 are added by web service calls Node node10 = createNode("node10", "host10.yahoo.com", ipAddresses, Optional.of("parent1.yahoo.com"), flavors.getFlavorOrThrow("default"), NodeType.tenant); Status node10newStatus = node10.status(); node10newStatus = node10newStatus @@ -95,6 +96,11 @@ public class MockNodeRepository extends NodeRepository { node10 = node10.with(node10newStatus); nodes.add(node10); + Node node13 = createNode("node13", "host13.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.tenant); + Node node14 = createNode("node14", "host14.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.tenant); + nodes.add(node13); + nodes.add(node14); + Node node55 = createNode("node55", "host55.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant); nodes.add(node55.with(node55.status().withWantToRetire(true).withWantToDeprovision(true))); @@ -109,18 +115,17 @@ public class MockNodeRepository extends NodeRepository { nodes.add(createNode("cfg1", "cfg1.yahoo.com", Collections.singleton("127.0.1.1"), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.config)); nodes.add(createNode("cfg2", "cfg2.yahoo.com", Collections.singleton("127.0.1.2"), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.config)); + // Ready all nodes, except 7 and 55 nodes = addNodes(nodes); - nodes.remove(6); - nodes.remove(7); + nodes.remove(node7); + nodes.remove(node55); nodes = setDirty(nodes, Agent.system, getClass().getSimpleName()); setReady(nodes, Agent.system, getClass().getSimpleName()); - fail("host5.yahoo.com", Agent.system, getClass().getSimpleName()); - dirtyRecursively("host55.yahoo.com", Agent.system, getClass().getSimpleName()); + fail(node5.hostname(), Agent.system, getClass().getSimpleName()); + dirtyRecursively(node55.hostname(), Agent.system, getClass().getSimpleName()); ApplicationId zoneApp = ApplicationId.from(TenantName.from("zoneapp"), ApplicationName.from("zoneapp"), InstanceName.from("zoneapp")); - // TODO: Remove this once feature flag is removed - this.flags().setEnabled(FlagId.exclusiveLoadBalancer, zoneApp, true); ClusterSpec zoneCluster = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("node-admin"), Version.fromString("6.42"), @@ -148,6 +153,13 @@ public class MockNodeRepository extends NodeRepository { Version.fromString("6.42"), false, Collections.emptySet()); activate(provisioner.prepare(app3, cluster3, Capacity.fromNodeCount(2, Optional.of("docker"), false, true), 1, null), app3, provisioner); + + ApplicationId app4 = ApplicationId.from(TenantName.from("tenant4"), ApplicationName.from("application4"), InstanceName.from("instance4")); + ClusterSpec cluster4 = ClusterSpec.request(ClusterSpec.Type.container, + ClusterSpec.Id.from("id4"), + Version.fromString("6.42"), + false, Collections.emptySet()); + activate(provisioner.prepare(app4, cluster4, Capacity.fromNodeCount(2, Optional.of("large"), false, true), 1, null), app4, provisioner); } private void activate(List<HostSpec> hosts, ApplicationId application, NodeRepositoryProvisioner provisioner) { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/flag/FlagsTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/flag/FlagsTest.java deleted file mode 100644 index 5018b18c491..00000000000 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/flag/FlagsTest.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.provision.flag; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; -import com.yahoo.vespa.curator.mock.MockCurator; -import com.yahoo.vespa.hosted.provision.NodeRepository; -import com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors; -import com.yahoo.vespa.hosted.provision.testutils.MockNodeRepository; -import org.junit.Test; - -import java.util.function.Supplier; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * @author mpolden - */ -public class FlagsTest { - - @Test - public void test_flag_toggling() { - NodeRepository nodeRepository = new MockNodeRepository(new MockCurator(), new MockNodeFlavors()); - Flags flags = nodeRepository.flags(); - Supplier<Flag> flag = () -> flags.get(FlagId.exclusiveLoadBalancer); - - // Flag is disabled by default - assertFalse(flag.get().isEnabled()); - - // Toggle flag for a node - { - HostName node1 = HostName.from("host1"); - flags.setEnabled(FlagId.exclusiveLoadBalancer, node1, true); - assertTrue(flag.get().isEnabled(node1)); - assertFalse(flag.get().isEnabled()); - flags.setEnabled(FlagId.exclusiveLoadBalancer, node1, false); - assertFalse(flag.get().isEnabled(node1)); - } - - // Toggle flag for an application - { - ApplicationId app1 = ApplicationId.from("tenant1", "application1", "default"); - flags.setEnabled(FlagId.exclusiveLoadBalancer, app1, true); - assertTrue(flag.get().isEnabled(app1)); - assertFalse(flag.get().isEnabled()); - flags.setEnabled(FlagId.exclusiveLoadBalancer, app1, false); - assertFalse(flag.get().isEnabled(app1)); - } - - // Toggle flag globally - { - flags.setEnabled(FlagId.exclusiveLoadBalancer, true); - assertTrue(flag.get().isEnabled()); - // Flag is implicitly enabled for all dimensions - assertTrue(flag.get().isEnabled(HostName.from("host1"))); - assertTrue(flag.get().isEnabled(ApplicationId.from("tenant1", "application1", "default"))); - flags.setEnabled(FlagId.exclusiveLoadBalancer, false); - assertFalse(flag.get().isEnabled()); - } - } - - -} diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/LoadBalancerExpirerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/LoadBalancerExpirerTest.java index 9870b94a8d5..52d297232de 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/LoadBalancerExpirerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/LoadBalancerExpirerTest.java @@ -6,7 +6,6 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostSpec; import com.yahoo.transaction.NestedTransaction; -import com.yahoo.vespa.hosted.provision.flag.FlagId; import com.yahoo.vespa.hosted.provision.lb.LoadBalancer; import com.yahoo.vespa.hosted.provision.lb.LoadBalancerId; import com.yahoo.vespa.hosted.provision.node.Agent; @@ -36,7 +35,6 @@ public class LoadBalancerExpirerTest { Duration.ofDays(1), new JobControl(tester.nodeRepository().database()), tester.loadBalancerService()); - tester.nodeRepository().flags().setEnabled(FlagId.exclusiveLoadBalancer, true); Supplier<Map<LoadBalancerId, LoadBalancer>> loadBalancers = () -> tester.nodeRepository().database().readLoadBalancers(); // Deploy two applications with load balancers diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/FlagSerializerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/FlagSerializerTest.java deleted file mode 100644 index 15f2289d340..00000000000 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/FlagSerializerTest.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.provision.persistence; - -import com.google.common.collect.ImmutableSet; -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.hosted.provision.flag.Flag; -import com.yahoo.vespa.hosted.provision.flag.FlagId; -import org.junit.Test; - -import java.util.Collections; - -import static org.junit.Assert.assertEquals; - -/** - * @author mpolden - */ -public class FlagSerializerTest { - - @Test - public void test_serialization() { - Flag flag = new Flag(FlagId.exclusiveLoadBalancer, true, - ImmutableSet.of("host1", "host2"), - Collections.singleton( - ApplicationId.from("tenant1", "application1", "default") - )); - Flag serialized = FlagSerializer.fromJson(FlagSerializer.toJson(flag)); - assertEquals(flag.id(), serialized.id()); - assertEquals(flag.isEnabled(), serialized.isEnabled()); - assertEquals(flag.hostnames(), serialized.hostnames()); - assertEquals(flag.applications(), serialized.applications()); - } - -} diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AclProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AclProvisioningTest.java index 46fd2183faa..a55211a112a 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AclProvisioningTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AclProvisioningTest.java @@ -9,7 +9,6 @@ import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.NodeType; import com.yahoo.vespa.hosted.provision.Node; -import com.yahoo.vespa.hosted.provision.flag.FlagId; import com.yahoo.vespa.hosted.provision.node.NodeAcl; import org.junit.Test; @@ -57,15 +56,9 @@ public class AclProvisioningTest { Supplier<List<NodeAcl>> nodeAcls = () -> tester.nodeRepository().getNodeAcls(node, false); // Trusted nodes is active nodes in same application, proxy nodes and config servers - assertAcls(Arrays.asList(activeNodes, proxyNodes, configServers, dockerHost), nodeAcls.get()); - - // Allocate load balancer - tester.nodeRepository().flags().setEnabled(FlagId.exclusiveLoadBalancer, application, true); - deploy(application, 2); - - // Load balancer networks are added to ACLs assertAcls(Arrays.asList(activeNodes, proxyNodes, configServers, dockerHost), - ImmutableSet.of("10.2.3.0/24", "10.4.5.0/24"), nodeAcls.get()); + ImmutableSet.of("10.2.3.0/24", "10.4.5.0/24"), + nodeAcls.get()); } @Test diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java index 2ed15b0a06f..4f7e09d0bd7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java @@ -10,7 +10,6 @@ import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.RotationName; import com.yahoo.transaction.NestedTransaction; import com.yahoo.vespa.hosted.provision.Node; -import com.yahoo.vespa.hosted.provision.flag.FlagId; import com.yahoo.vespa.hosted.provision.lb.LoadBalancer; import com.yahoo.vespa.hosted.provision.lb.LoadBalancerInstance; import com.yahoo.vespa.hosted.provision.lb.Real; @@ -44,7 +43,6 @@ public class LoadBalancerProvisionerTest { ClusterSpec.Id containerCluster1 = ClusterSpec.Id.from("qrs1"); ClusterSpec.Id contentCluster = ClusterSpec.Id.from("content"); Set<RotationName> rotationsCluster1 = Set.of(RotationName.from("r1-1"), RotationName.from("r1-2")); - tester.nodeRepository().flags().setEnabled(FlagId.exclusiveLoadBalancer, true); tester.activate(app1, prepare(app1, clusterRequest(ClusterSpec.Type.container, containerCluster1, rotationsCluster1), clusterRequest(ClusterSpec.Type.content, contentCluster))); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java index 04664bd1d16..75995245274 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java @@ -49,7 +49,7 @@ public class RestApiTest { @After public void stopContainer() { - container.close(); + if (container != null) container.close(); } /** This test gives examples of all the requests that can be made to nodes/v2 */ @@ -76,17 +76,17 @@ public class RestApiTest { new byte[0], Request.Method.POST)); assertRestart(2, new Request("http://localhost:8080/nodes/v2/command/restart?application=tenant2.application2.instance2", new byte[0], Request.Method.POST)); - assertRestart(9, new Request("http://localhost:8080/nodes/v2/command/restart", + assertRestart(11, new Request("http://localhost:8080/nodes/v2/command/restart", new byte[0], Request.Method.POST)); assertResponseContains(new Request("http://localhost:8080/nodes/v2/node/host2.yahoo.com"), "\"restartGeneration\":3"); // POST reboot command - assertReboot(10, new Request("http://localhost:8080/nodes/v2/command/reboot?state=failed%20active", + assertReboot(12, new Request("http://localhost:8080/nodes/v2/command/reboot?state=failed%20active", new byte[0], Request.Method.POST)); assertReboot(2, new Request("http://localhost:8080/nodes/v2/command/reboot?application=tenant2.application2.instance2", new byte[0], Request.Method.POST)); - assertReboot(17, new Request("http://localhost:8080/nodes/v2/command/reboot", + assertReboot(19, new Request("http://localhost:8080/nodes/v2/command/reboot", new byte[0], Request.Method.POST)); assertResponseContains(new Request("http://localhost:8080/nodes/v2/node/host2.yahoo.com"), "\"rebootGeneration\":4"); @@ -778,49 +778,11 @@ public class RestApiTest { "{\"message\":\"Cancelled outstanding requests for firmware checks\"}"); } - @Test - public void test_flags() throws Exception { - assertFile(new Request("http://localhost:8080/nodes/v2/flags/"), "flags1.json"); - - // Enable flag for application - assertResponse(new Request("http://localhost:8080/nodes/v2/flags/exclusive-load-balancer/application/foo:bar:default", - new byte[0], Request.Method.POST), - "{\"message\":\"Enabled feature exclusiveLoadBalancer for application 'foo:bar:default'\"}"); - - // Enable flag for node - assertResponse(new Request("http://localhost:8080/nodes/v2/flags/exclusive-load-balancer/node/host1", - new byte[0], Request.Method.POST), - "{\"message\":\"Enabled feature exclusiveLoadBalancer for node 'host1'\"}"); - - assertFile(new Request("http://localhost:8080/nodes/v2/flags/"), "flags2.json"); - - // Enable flag for entire repository - assertResponse(new Request("http://localhost:8080/nodes/v2/flags/exclusive-load-balancer", - new byte[0], Request.Method.POST), - "{\"message\":\"Enabled feature exclusiveLoadBalancer\"}"); - - // Disable flag for application - assertResponse(new Request("http://localhost:8080/nodes/v2/flags/exclusive-load-balancer/application/foo:bar:default", - new byte[0], Request.Method.DELETE), - "{\"message\":\"Disabled feature exclusiveLoadBalancer for application 'foo:bar:default'\"}"); - - // Disable flag for node - assertResponse(new Request("http://localhost:8080/nodes/v2/flags/exclusive-load-balancer/node/host1", - new byte[0], Request.Method.DELETE), - "{\"message\":\"Disabled feature exclusiveLoadBalancer for node 'host1'\"}"); - - // Disable flag for entire repository - assertResponse(new Request("http://localhost:8080/nodes/v2/flags/exclusive-load-balancer", - new byte[0], Request.Method.DELETE), - "{\"message\":\"Disabled feature exclusiveLoadBalancer\"}"); - - } - /** Tests the rendering of each node separately to make it easier to find errors */ @Test public void test_single_node_rendering() throws Exception { - for (int i = 1; i <= 10; i++) { - if (i == 8 || i == 9) continue; // these nodes are added later + for (int i = 1; i <= 14; i++) { + if (i == 8 || i == 9 || i == 11 || i == 12) continue; // these nodes are added later assertFile(new Request("http://localhost:8080/nodes/v2/node/host" + i + ".yahoo.com"), "node" + i + ".json"); } } @@ -828,7 +790,7 @@ public class RestApiTest { @Test public void test_load_balancers() throws Exception { assertFile(new Request("http://localhost:8080/loadbalancers/v1/"), "load-balancers.json"); - assertFile(new Request("http://localhost:8080/loadbalancers/v1/?application=zoneapp.zoneapp.zoneapp"), "load-balancers.json"); + assertFile(new Request("http://localhost:8080/loadbalancers/v1/?application=tenant4.application4.instance4"), "load-balancers.json"); assertResponse(new Request("http://localhost:8080/loadbalancers/v1/?application=tenant.nonexistent.default"), "{\"loadBalancers\":[]}"); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-config-server.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-config-server.json index 92b5885cde4..05fa3e8ad72 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-config-server.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-config-server.json @@ -97,6 +97,30 @@ "trustedBy": "cfg1.yahoo.com" }, { + "hostname": "host13.yahoo.com", + "type": "tenant", + "ipAddress": "127.0.0.1", + "trustedBy": "cfg1.yahoo.com" + }, + { + "hostname": "host13.yahoo.com", + "type": "tenant", + "ipAddress": "::1", + "trustedBy": "cfg1.yahoo.com" + }, + { + "hostname": "host14.yahoo.com", + "type": "tenant", + "ipAddress": "127.0.0.1", + "trustedBy": "cfg1.yahoo.com" + }, + { + "hostname": "host14.yahoo.com", + "type": "tenant", + "ipAddress": "::1", + "trustedBy": "cfg1.yahoo.com" + }, + { "hostname": "host2.yahoo.com", "type": "tenant", "ipAddress": "127.0.0.1", diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-tenant-node.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-tenant-node.json index 66d92ecc9fe..75c9aaa2b5c 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-tenant-node.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/acl-tenant-node.json @@ -43,6 +43,30 @@ "trustedBy": "foo.yahoo.com" }, { + "hostname": "host13.yahoo.com", + "type": "tenant", + "ipAddress": "127.0.0.1", + "trustedBy": "foo.yahoo.com" + }, + { + "hostname": "host13.yahoo.com", + "type": "tenant", + "ipAddress": "::1", + "trustedBy": "foo.yahoo.com" + }, + { + "hostname": "host14.yahoo.com", + "type": "tenant", + "ipAddress": "127.0.0.1", + "trustedBy": "foo.yahoo.com" + }, + { + "hostname": "host14.yahoo.com", + "type": "tenant", + "ipAddress": "::1", + "trustedBy": "foo.yahoo.com" + }, + { "hostname": "host2.yahoo.com", "type": "tenant", "ipAddress": "127.0.0.1", diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/active-nodes.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/active-nodes.json index 9c462bb5520..a5d8148c1e4 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/active-nodes.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/active-nodes.json @@ -1,7 +1,9 @@ { "nodes": [ @include(node6.json), + @include(node13.json), @include(node2.json), + @include(node14.json), @include(docker-container1.json), @include(node4.json), @include(docker-node4.json), diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/load-balancers.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/load-balancers.json index e3baa069907..c8738ab838c 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/load-balancers.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/load-balancers.json @@ -1,12 +1,12 @@ { "loadBalancers": [ { - "id": "zoneapp:zoneapp:zoneapp:node-admin", - "application": "zoneapp", - "tenant": "zoneapp", - "instance": "zoneapp", - "cluster": "node-admin", - "hostname": "lb-zoneapp.zoneapp.zoneapp-node-admin", + "id": "tenant4:application4:instance4:id4", + "application": "application4", + "tenant": "tenant4", + "instance": "instance4", + "cluster": "id4", + "hostname": "lb-tenant4.application4.instance4-id4", "dnsZone": "zone-id-1", "networks": [ "10.2.3.0/24", @@ -17,36 +17,17 @@ ], "reals": [ { - "hostname": "dockerhost1.yahoo.com", + "hostname": "host13.yahoo.com", "ipAddress": "127.0.0.1", "port": 4080 }, { - "hostname": "dockerhost2.yahoo.com", + "hostname": "host14.yahoo.com", "ipAddress": "127.0.0.1", "port": 4080 - }, - { - "hostname": "dockerhost3.yahoo.com", - "ipAddress": "127.0.0.1", - "port": 4080 - }, - { - "hostname": "dockerhost4.yahoo.com", - "ipAddress": "127.0.0.1", - "port": 4080 - }, - { - "hostname": "dockerhost5.yahoo.com", - "ipAddress": "127.0.0.1", - "port": 4080 - } - ], - "rotations": [ - { - "name": "us-cluster" } ], + "rotations": [], "inactive": false } ] diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node13.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node13.json new file mode 100644 index 00000000000..1584231f208 --- /dev/null +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node13.json @@ -0,0 +1,67 @@ +{ + "url": "http://localhost:8080/nodes/v2/node/host13.yahoo.com", + "id": "host13.yahoo.com", + "state": "active", + "type": "tenant", + "hostname": "host13.yahoo.com", + "openStackId": "node13", + "flavor": "large", + "canonicalFlavor": "large", + "minDiskAvailableGb": 1600.0, + "minMainMemoryAvailableGb": 32.0, + "description": "Flavor-name-is-large", + "minCpuCores": 4.0, + "fastDisk": true, + "bandwidth": 0.0, + "environment": "BARE_METAL", + "owner": { + "tenant": "tenant4", + "application": "application4", + "instance": "instance4" + }, + "membership": { + "clustertype": "container", + "clusterid": "id4", + "group": "0", + "index": 0, + "retired": false + }, + "restartGeneration": 0, + "currentRestartGeneration": 0, + "wantedDockerImage": "docker-registry.domain.tld:8080/dist/vespa:6.42.0", + "wantedVespaVersion": "6.42.0", + "allowedToBeDown": false, + "rebootGeneration": 1, + "currentRebootGeneration": 0, + "failCount": 0, + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { + "event": "readied", + "at": 123, + "agent": "system" + }, + { + "event": "reserved", + "at": 123, + "agent": "application" + }, + { + "event": "activated", + "at": 123, + "agent": "application" + } + ], + "ipAddresses": [ + "127.0.0.1", + "::1" + ], + "additionalIpAddresses": [] +} diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node14.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node14.json new file mode 100644 index 00000000000..462f6e2433f --- /dev/null +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node14.json @@ -0,0 +1,67 @@ +{ + "url": "http://localhost:8080/nodes/v2/node/host14.yahoo.com", + "id": "host14.yahoo.com", + "state": "active", + "type": "tenant", + "hostname": "host14.yahoo.com", + "openStackId": "node14", + "flavor": "large", + "canonicalFlavor": "large", + "minDiskAvailableGb": 1600.0, + "minMainMemoryAvailableGb": 32.0, + "description": "Flavor-name-is-large", + "minCpuCores": 4.0, + "fastDisk": true, + "bandwidth": 0.0, + "environment": "BARE_METAL", + "owner": { + "tenant": "tenant4", + "application": "application4", + "instance": "instance4" + }, + "membership": { + "clustertype": "container", + "clusterid": "id4", + "group": "0", + "index": 1, + "retired": false + }, + "restartGeneration": 0, + "currentRestartGeneration": 0, + "wantedDockerImage": "docker-registry.domain.tld:8080/dist/vespa:6.42.0", + "wantedVespaVersion": "6.42.0", + "allowedToBeDown": false, + "rebootGeneration": 1, + "currentRebootGeneration": 0, + "failCount": 0, + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { + "event": "readied", + "at": 123, + "agent": "system" + }, + { + "event": "reserved", + "at": 123, + "agent": "application" + }, + { + "event": "activated", + "at": 123, + "agent": "application" + } + ], + "ipAddresses": [ + "127.0.0.1", + "::1" + ], + "additionalIpAddresses": [] +} diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes-recursive.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes-recursive.json index 57aee72e9f8..5f51f53fb2b 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes-recursive.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes-recursive.json @@ -10,9 +10,11 @@ @include(node6.json), @include(docker-node5.json), @include(docker-node2.json), + @include(node13.json), @include(node2.json), @include(docker-node1.json), @include(docker-node3.json), + @include(node14.json), @include(docker-container1.json), @include(node4.json), @include(node55.json), diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes.json index 1c069951750..8f29a774fb4 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/nodes.json @@ -31,6 +31,9 @@ "url": "http://localhost:8080/nodes/v2/node/dockerhost2.yahoo.com" }, { + "url": "http://localhost:8080/nodes/v2/node/host13.yahoo.com" + }, + { "url": "http://localhost:8080/nodes/v2/node/host2.yahoo.com" }, { @@ -40,6 +43,9 @@ "url": "http://localhost:8080/nodes/v2/node/dockerhost3.yahoo.com" }, { + "url": "http://localhost:8080/nodes/v2/node/host14.yahoo.com" + }, + { "url": "http://localhost:8080/nodes/v2/node/test-container-1" }, { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/states-recursive.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/states-recursive.json index e60ebe37246..5d90346eec7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/states-recursive.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/states-recursive.json @@ -25,7 +25,9 @@ "url": "http://localhost:8080/nodes/v2/state/active", "nodes": [ @include(node6.json), + @include(node13.json), @include(node2.json), + @include(node14.json), @include(docker-container1.json), @include(node4.json), @include(docker-node4.json), |