summaryrefslogtreecommitdiffstats
path: root/flags
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@verizonmedia.com>2019-09-09 15:58:03 +0200
committerValerij Fredriksen <valerijf@verizonmedia.com>2019-09-09 15:58:03 +0200
commitf8b160a34c50402e3187eaac6afaeb66e2dd1d04 (patch)
treee928345809c352e78f2838eda71009dba7338f1a /flags
parent2774561e5637922a5950440d9d2136939103285a (diff)
Define new provisioning flags
Diffstat (limited to 'flags')
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/FetchVector.java8
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/Flags.java18
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/custom/NodeResources.java90
3 files changed, 111 insertions, 5 deletions
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/FetchVector.java b/flags/src/main/java/com/yahoo/vespa/flags/FetchVector.java
index c2fc0352d17..7c4fc307b99 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/FetchVector.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/FetchVector.java
@@ -33,12 +33,18 @@ public class FetchVector {
* <p>Value from ZoneId::value is of the form environment.region.
*/
ZONE_ID,
+
/** Value from ApplicationId::serializedForm of the form tenant:applicationName:instance. */
APPLICATION_ID,
+
/** Fully qualified hostname */
HOSTNAME,
+
/** Node type from com.yahoo.config.provision.NodeType::name, e.g. tenant, host, confighost, controller, etc. */
- NODE_TYPE
+ NODE_TYPE,
+
+ /** Cluster type, e.g. content, container, admin */
+ CLUSTER_TYPE
}
private final Map<Dimension, String> map;
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
index 92a18a3094b..a97b021e9f3 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.flags;
import com.yahoo.vespa.defaults.Defaults;
+import com.yahoo.vespa.flags.custom.NodeResources;
import com.yahoo.vespa.flags.custom.PreprovisionCapacity;
import java.util.List;
@@ -9,6 +10,7 @@ import java.util.Optional;
import java.util.TreeMap;
import static com.yahoo.vespa.flags.FetchVector.Dimension.APPLICATION_ID;
+import static com.yahoo.vespa.flags.FetchVector.Dimension.CLUSTER_TYPE;
import static com.yahoo.vespa.flags.FetchVector.Dimension.HOSTNAME;
import static com.yahoo.vespa.flags.FetchVector.Dimension.NODE_TYPE;
@@ -119,10 +121,18 @@ public class Flags {
"preprovisioned is taken, new will be provisioned within next iteration of maintainer.",
"Takes effect on next iteration of HostProivisionMaintainer.");
- public static final UnboundListFlag<String> DISABLED_DYNAMIC_PROVISIONING_FLAVORS = defineListFlag(
- "disabled-dynamic-provisioning-flavors", List.of(), String.class,
- "List of disabled Vespa flavor names that cannot be used for dynamic provisioning",
- "Takes effect on next provisioning");
+ public static final UnboundBooleanFlag USE_ADVERTISED_RESOURCES = defineFeatureFlag(
+ "use-advertised-resources", false,
+ "When enabled, will use advertised host resources rather than actual host resources, ignore host resource " +
+ "reservation, and fail with exception unless requested resource match advertised host resources exactly.",
+ "Takes effect on next iteration of HostProivisionMaintainer.",
+ APPLICATION_ID);
+
+ public static final UnboundJacksonFlag<NodeResources> DEFAULT_RESOURCES = defineJacksonFlag(
+ "default-resources", null, NodeResources.class,
+ "Node resources that will be used when not specified in services.xml",
+ "Takes effect on next deployment",
+ CLUSTER_TYPE);
public static final UnboundBooleanFlag ENABLE_DISK_WRITE_TEST = defineFeatureFlag(
"enable-disk-write-test", false,
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/custom/NodeResources.java b/flags/src/main/java/com/yahoo/vespa/flags/custom/NodeResources.java
new file mode 100644
index 00000000000..d555e442b70
--- /dev/null
+++ b/flags/src/main/java/com/yahoo/vespa/flags/custom/NodeResources.java
@@ -0,0 +1,90 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.flags.custom;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * @author freva
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class NodeResources {
+ private static final Set<String> validDiskSpeeds = Set.of("any", "slow", "fast");
+
+ @JsonProperty("vcpu")
+ private final double vcpu;
+
+ @JsonProperty("memoryGb")
+ private final double memoryGb;
+
+ @JsonProperty("diskGb")
+ private final double diskGb;
+
+ @JsonProperty("bandwidthGbps")
+ private final double bandwidthGbps;
+
+ @JsonProperty("diskSpeed")
+ private final String diskSpeed;
+
+ public NodeResources(@JsonProperty("vcpu") double vcpu,
+ @JsonProperty("memoryGb") double memoryGb,
+ @JsonProperty("diskGb") double diskGb,
+ @JsonProperty("bandwidthGbps") Double bandwidthGbps,
+ @JsonProperty("diskSpeed") String diskSpeed) {
+ this.vcpu = requirePositive("vcpu", vcpu);
+ this.memoryGb = requirePositive("memoryGb", memoryGb);
+ this.diskGb = requirePositive("diskGb", diskGb);
+ this.bandwidthGbps = (int) requirePositive("bandwidthGbps", Optional.ofNullable(bandwidthGbps).orElse(0.3));
+ this.diskSpeed = Optional.ofNullable(diskSpeed).orElse("fast");
+
+ if (!validDiskSpeeds.contains(this.diskSpeed))
+ throw new IllegalArgumentException("Invalid diskSpeed, valid values are: " + validDiskSpeeds + ", got: " + diskSpeed);
+ }
+
+ public double vcpu() {
+ return vcpu;
+ }
+
+ public double memoryGb() {
+ return memoryGb;
+ }
+
+ public double diskGb() {
+ return diskGb;
+ }
+
+ public double bandwidthGbps() {
+ return bandwidthGbps;
+ }
+
+ public String diskSpeed() {
+ return diskSpeed;
+ }
+
+ private static double requirePositive(String name, double value) {
+ if (value < 1)
+ throw new IllegalArgumentException("'" + name + "' must be positive, was " + value);
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ NodeResources resources = (NodeResources) o;
+ return Double.compare(resources.vcpu, vcpu) == 0 &&
+ Double.compare(resources.memoryGb, memoryGb) == 0 &&
+ Double.compare(resources.diskGb, diskGb) == 0 &&
+ Double.compare(resources.bandwidthGbps, bandwidthGbps) == 0 &&
+ diskSpeed.equals(resources.diskSpeed);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(vcpu, memoryGb, diskGb, bandwidthGbps, diskSpeed);
+ }
+}