summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-08-14 15:18:43 +0200
committerJon Bratseth <bratseth@verizonmedia.com>2019-08-14 15:18:43 +0200
commitdd188dbb522a2d8d1b90fdc278225aaca6191dce (patch)
treee60a1921bd7898c1d19be7db8a77f998febcd6c8 /config-provisioning
parente134f307f2e962d07ae2cf5a6299e355dc618a41 (diff)
Remove flavor replaces concept
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java48
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java22
-rw-r--r--config-provisioning/src/main/resources/configdefinitions/flavors.def6
-rw-r--r--config-provisioning/src/test/java/com/yahoo/config/provision/NodeFlavorsTest.java22
4 files changed, 10 insertions, 88 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java
index 93ca0a77806..dd33cd58d1d 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java
@@ -22,7 +22,6 @@ public class Flavor {
private final Type type;
private final double bandwidth;
private final boolean retired;
- private List<Flavor> replacesFlavors;
/** The hardware resources of this flavor */
private NodeResources resources;
@@ -39,7 +38,6 @@ public class Flavor {
flavorConfig.fastDisk() ? NodeResources.DiskSpeed.fast : NodeResources.DiskSpeed.slow);
this.bandwidth = flavorConfig.bandwidth();
this.retired = flavorConfig.retired();
- this.replacesFlavors = new ArrayList<>();
}
/** Creates a *node* flavor from a node resources spec */
@@ -51,7 +49,6 @@ public class Flavor {
this.type = Type.DOCKER_CONTAINER;
this.bandwidth = 1;
this.retired = false;
- this.replacesFlavors = List.of();
this.resources = resources;
}
@@ -94,54 +91,15 @@ public class Flavor {
/** Convenience, returns getType() == Type.DOCKER_CONTAINER */
public boolean isDocker() { return type == Type.DOCKER_CONTAINER; }
- /**
- * Returns the canonical name of this flavor - which is the name which should be used as an interface to users.
- * The canonical name of this flavor is:
- * <ul>
- * <li>If it replaces one flavor, the canonical name of the flavor it replaces
- * <li>If it replaces multiple or no flavors - itself
- * </ul>
- *
- * The logic is that we can use this to capture the gritty details of configurations in exact flavor names
- * but also encourage users to refer to them by a common name by letting such flavor variants declare that they
- * replace the canonical name we want. However, if a node replaces multiple names, we have no basis for choosing one
- * of them as the canonical, so we return the current as canonical.
- */
public String canonicalName() {
- return isCanonical() ? name : replacesFlavors.get(0).canonicalName();
+ return name;
}
- /** Returns whether this is a canonical flavor */
- public boolean isCanonical() {
- return replacesFlavors.size() != 1;
- }
-
/**
- * The flavors this (directly) replaces.
- * This is immutable if this is frozen, and a mutable list otherwise.
- */
- public List<Flavor> replaces() { return replacesFlavors; }
-
- /**
- * Returns whether this flavor satisfies the requested flavor, either directly
- * (by being the same), or by directly or indirectly replacing it
+ * Returns whether this flavor satisfies the requested flavor
*/
public boolean satisfies(Flavor flavor) {
- if (this.equals(flavor)) {
- return true;
- }
- if (this.retired) {
- return false;
- }
- for (Flavor replaces : replacesFlavors)
- if (replaces.satisfies(flavor))
- return true;
- return false;
- }
-
- /** Irreversibly freezes the content of this */
- public void freeze() {
- replacesFlavors = List.copyOf(replacesFlavors);
+ return this.equals(flavor);
}
@Override
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java
index 5dbfc413de4..a76c50702c6 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java
@@ -68,25 +68,11 @@ public class NodeFlavors {
for (FlavorsConfig.Flavor flavorConfig : config.flavor()) {
flavors.put(flavorConfig.name(), new Flavor(flavorConfig));
}
- // Second pass, set flavorReplacesConfig to point to correct flavor.
- for (FlavorsConfig.Flavor flavorConfig : config.flavor()) {
- Flavor flavor = flavors.get(flavorConfig.name());
- for (FlavorsConfig.Flavor.Replaces flavorReplacesConfig : flavorConfig.replaces()) {
- if (! flavors.containsKey(flavorReplacesConfig.name())) {
- throw new IllegalStateException("Replaces for " + flavor.name() +
- " pointing to a non existing flavor: " + flavorReplacesConfig.name());
- }
- flavor.replaces().add(flavors.get(flavorReplacesConfig.name()));
- }
- flavor.freeze();
- }
- // Third pass, ensure that retired flavors have a replacement
+
+ // Ensure that retired flavors have a replacement
for (Flavor flavor : flavors.values()) {
- if (flavor.isRetired() && !hasReplacement(flavors.values(), flavor)) {
- throw new IllegalStateException(
- String.format("Flavor '%s' is retired, but has no replacement", flavor.name())
- );
- }
+ if (flavor.isRetired() && !hasReplacement(flavors.values(), flavor))
+ throw new IllegalStateException(String.format("Flavor '%s' is retired, but has no replacement", flavor.name()));
}
return flavors.values();
}
diff --git a/config-provisioning/src/main/resources/configdefinitions/flavors.def b/config-provisioning/src/main/resources/configdefinitions/flavors.def
index 6d2a981427e..fc09527ba01 100644
--- a/config-provisioning/src/main/resources/configdefinitions/flavors.def
+++ b/config-provisioning/src/main/resources/configdefinitions/flavors.def
@@ -7,11 +7,7 @@ namespace=config.provisioning
# If a certain flavor has no config it is not necessary to list it here to use it.
flavor[].name string
-# Names of other flavors (whether mentioned in this config or not) which this flavor
-# is a replacement for: If one of these flavor names are requested, this flavor may
-# be assigned instead.
-# Replacements are transitive: If flavor a replaces b replaces c, then a request for flavor
-# c may be satisfied by assigning nodes of flavor a.
+# NOT USED
flavor[].replaces[].name string
# The monthly Total Cost of Ownership (TCO) in USD. Typically calculated as TCO divided by
diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/NodeFlavorsTest.java b/config-provisioning/src/test/java/com/yahoo/config/provision/NodeFlavorsTest.java
index 55ffa821e26..6e536745c33 100644
--- a/config-provisioning/src/test/java/com/yahoo/config/provision/NodeFlavorsTest.java
+++ b/config-provisioning/src/test/java/com/yahoo/config/provision/NodeFlavorsTest.java
@@ -9,9 +9,7 @@ import org.junit.rules.ExpectedException;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
+import static org.junit.Assert.assertEquals;
public class NodeFlavorsTest {
@@ -19,22 +17,6 @@ public class NodeFlavorsTest {
public final ExpectedException exception = ExpectedException.none();
@Test
- public void testReplacesWithBadValue() {
- FlavorsConfig.Builder builder = new FlavorsConfig.Builder();
- List<FlavorsConfig.Flavor.Builder> flavorBuilderList = new ArrayList<>();
- FlavorsConfig.Flavor.Builder flavorBuilder = new FlavorsConfig.Flavor.Builder();
- FlavorsConfig.Flavor.Replaces.Builder flavorReplacesBuilder = new FlavorsConfig.Flavor.Replaces.Builder();
- flavorReplacesBuilder.name("non-existing-config");
- flavorBuilder.name("strawberry").cost(2).replaces.add(flavorReplacesBuilder);
- flavorBuilderList.add(flavorBuilder);
- builder.flavor(flavorBuilderList);
- FlavorsConfig config = new FlavorsConfig(builder);
- exception.expect(IllegalStateException.class);
- exception.expectMessage("Replaces for strawberry pointing to a non existing flavor: non-existing-config");
- new NodeFlavors(config);
- }
-
- @Test
public void testConfigParsing() {
FlavorsConfig.Builder builder = new FlavorsConfig.Builder();
List<FlavorsConfig.Flavor.Builder> flavorBuilderList = new ArrayList<>();
@@ -53,7 +35,7 @@ public class NodeFlavorsTest {
builder.flavor(flavorBuilderList);
FlavorsConfig config = new FlavorsConfig(builder);
NodeFlavors nodeFlavors = new NodeFlavors(config);
- assertThat(nodeFlavors.getFlavor("banana").get().cost(), is(3));
+ assertEquals(3, nodeFlavors.getFlavor("banana").get().cost());
}
@Test