aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-11-18 13:27:22 +0100
committerGitHub <noreply@github.com>2022-11-18 13:27:22 +0100
commitadd8c45ce4753256356efd832a8a34ddbfaa4287 (patch)
tree6b87dce61119bb027eb88946d7ec36b46771a2f6
parent8bdf68624696be64182e559d61124326bb37a903 (diff)
parent2ed4d5b0ec5cca386863101e563e76ed289f8bee (diff)
Merge pull request #24919 from vespa-engine/mpolden/missing-compat-check
Fix missing compatibility check
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java11
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java17
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeResourcesSerializer.java86
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/FlavorConfigBuilder.java12
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java5
5 files changed, 79 insertions, 52 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java
index 836bf5f72d0..e03ebb4d8da 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java
@@ -15,6 +15,7 @@ public class NodeResources {
private static final double cpuUnitCost = 0.11;
private static final double memoryUnitCost = 0.011;
private static final double diskUnitCost = 0.0004;
+ private static final double gpuUnitCost = 0; // TODO(mpolden): Decide cost of this
private static final NodeResources zero = new NodeResources(0, 0, 0, 0);
private static final NodeResources unspecified = new NodeResources(0, 0, 0, 0);
@@ -134,7 +135,7 @@ public class NodeResources {
return count * memoryGb;
}
- public boolean lessThan(GpuResources other) {
+ private boolean lessThan(GpuResources other) {
return totalMemory() < other.totalMemory();
}
@@ -204,7 +205,10 @@ public class NodeResources {
/** Returns the standard cost of these resources, in dollars per hour */
public double cost() {
- return vcpu * cpuUnitCost + memoryGb * memoryUnitCost + diskGb * diskUnitCost;
+ return (vcpu * cpuUnitCost) +
+ (memoryGb * memoryUnitCost) +
+ (diskGb * diskUnitCost) +
+ (gpuResources.totalMemory() * gpuUnitCost);
}
public NodeResources withVcpu(double vcpu) {
@@ -297,6 +301,8 @@ public class NodeResources {
return false;
if (this.architecture != Architecture.any && other.architecture != Architecture.any && this.architecture != other.architecture)
return false;
+ if ( ! this.gpuResources.equals(other.gpuResources))
+ return false;
return true;
}
@@ -399,6 +405,7 @@ public class NodeResources {
else {
if (this.diskGb < requested.diskGb) return false;
}
+ if ( ! this.gpuResources.equals(requested.gpuResources)) return false;
if ( ! this.diskSpeed.compatibleWith(requested.diskSpeed)) return false;
if ( ! this.storageType.compatibleWith(requested.storageType)) return false;
if ( ! this.architecture.compatibleWith(requested.architecture)) return false;
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java
index f539bc19c49..3973b042bde 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java
@@ -49,6 +49,7 @@ public class AllocatedHostsSerializer {
private static final String diskSpeedKey = "diskSpeed";
private static final String storageTypeKey = "storageType";
private static final String architectureKey = "architecture";
+ private static final String gpuKey = "gpu";
private static final String gpuCountKey = "gpuCount";
private static final String gpuMemoryKey = "gpuMemory";
@@ -98,8 +99,9 @@ public class AllocatedHostsSerializer {
resourcesObject.setString(storageTypeKey, storageTypeToString(resources.storageType()));
resourcesObject.setString(architectureKey, architectureToString(resources.architecture()));
if (!resources.gpuResources().isDefault()) {
- resourcesObject.setLong(gpuCountKey, resources.gpuResources().count());
- resourcesObject.setDouble(gpuMemoryKey, resources.gpuResources().memoryGb());
+ Cursor gpuObject = resourcesObject.setObject(gpuKey);
+ gpuObject.setLong(gpuCountKey, resources.gpuResources().count());
+ gpuObject.setDouble(gpuMemoryKey, resources.gpuResources().memoryGb());
}
}
@@ -141,14 +143,13 @@ public class AllocatedHostsSerializer {
diskSpeedFromSlime(resources.field(diskSpeedKey)),
storageTypeFromSlime(resources.field(storageTypeKey)),
architectureFromSlime(resources.field(architectureKey)),
- gpuResourcesFromSlime(resources));
+ gpuResourcesFromSlime(resources.field(gpuKey)));
}
- private static NodeResources.GpuResources gpuResourcesFromSlime(Inspector resources) {
- Inspector gpuCountField = resources.field(gpuCountKey);
- Inspector gpuMemoryField = resources.field(gpuMemoryKey);
- if (!gpuCountField.valid() || !gpuMemoryField.valid()) return NodeResources.GpuResources.getDefault();
- return new NodeResources.GpuResources((int) gpuCountField.asLong(), gpuMemoryField.asDouble());
+ private static NodeResources.GpuResources gpuResourcesFromSlime(Inspector gpu) {
+ if (!gpu.valid()) return NodeResources.GpuResources.getDefault();
+ return new NodeResources.GpuResources((int) gpu.field(gpuCountKey).asLong(),
+ gpu.field(gpuMemoryKey).asDouble());
}
private static NodeResources optionalNodeResourcesFromSlime(Inspector resources) {
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeResourcesSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeResourcesSerializer.java
index f7be2b510c7..8843ce69994 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeResourcesSerializer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeResourcesSerializer.java
@@ -19,6 +19,9 @@ public class NodeResourcesSerializer {
private static final String diskSpeedKey = "diskSpeed";
private static final String storageTypeKey = "storageType";
private static final String architectureKey = "architecture";
+ private static final String gpuKey = "gpu";
+ private static final String gpuCountKey = "gpuCount";
+ private static final String gpuMemoryKey = "gpuMemory";
static void toSlime(NodeResources resources, Cursor resourcesObject) {
if (resources.isUnspecified()) return;
@@ -29,6 +32,11 @@ public class NodeResourcesSerializer {
resourcesObject.setString(diskSpeedKey, diskSpeedToString(resources.diskSpeed()));
resourcesObject.setString(storageTypeKey, storageTypeToString(resources.storageType()));
resourcesObject.setString(architectureKey, architectureToString(resources.architecture()));
+ if (!resources.gpuResources().isDefault()) {
+ Cursor gpuObject = resourcesObject.setObject(gpuKey);
+ gpuObject.setLong(gpuCountKey, resources.gpuResources().count());
+ gpuObject.setDouble(gpuMemoryKey, resources.gpuResources().memoryGb());
+ }
}
static NodeResources resourcesFromSlime(Inspector resources) {
@@ -39,7 +47,8 @@ public class NodeResourcesSerializer {
resources.field(bandwidthKey).asDouble(),
diskSpeedFromSlime(resources.field(diskSpeedKey)),
storageTypeFromSlime(resources.field(storageTypeKey)),
- architectureFromSlime(resources.field(architectureKey)));
+ architectureFromSlime(resources.field(architectureKey)),
+ gpuResourcesFromSlime(resources.field(gpuKey)));
}
static Optional<NodeResources> optionalResourcesFromSlime(Inspector resources) {
@@ -47,58 +56,61 @@ public class NodeResourcesSerializer {
}
private static NodeResources.DiskSpeed diskSpeedFromSlime(Inspector diskSpeed) {
- switch (diskSpeed.asString()) {
- case "fast" : return NodeResources.DiskSpeed.fast;
- case "slow" : return NodeResources.DiskSpeed.slow;
- case "any" : return NodeResources.DiskSpeed.any;
- default: throw new IllegalStateException("Illegal disk-speed value '" + diskSpeed.asString() + "'");
- }
+ return switch (diskSpeed.asString()) {
+ case "fast" -> NodeResources.DiskSpeed.fast;
+ case "slow" -> NodeResources.DiskSpeed.slow;
+ case "any" -> NodeResources.DiskSpeed.any;
+ default -> throw new IllegalStateException("Illegal disk-speed value '" + diskSpeed.asString() + "'");
+ };
}
private static String diskSpeedToString(NodeResources.DiskSpeed diskSpeed) {
- switch (diskSpeed) {
- case fast : return "fast";
- case slow : return "slow";
- case any : return "any";
- default: throw new IllegalStateException("Illegal disk-speed value '" + diskSpeed + "'");
- }
+ return switch (diskSpeed) {
+ case fast -> "fast";
+ case slow -> "slow";
+ case any -> "any";
+ };
}
private static NodeResources.StorageType storageTypeFromSlime(Inspector storageType) {
- switch (storageType.asString()) {
- case "remote" : return NodeResources.StorageType.remote;
- case "local" : return NodeResources.StorageType.local;
- case "any" : return NodeResources.StorageType.any;
- default: throw new IllegalStateException("Illegal storage-type value '" + storageType.asString() + "'");
- }
+ return switch (storageType.asString()) {
+ case "remote" -> NodeResources.StorageType.remote;
+ case "local" -> NodeResources.StorageType.local;
+ case "any" -> NodeResources.StorageType.any;
+ default -> throw new IllegalStateException("Illegal storage-type value '" + storageType.asString() + "'");
+ };
}
private static String storageTypeToString(NodeResources.StorageType storageType) {
- switch (storageType) {
- case remote : return "remote";
- case local : return "local";
- case any : return "any";
- default: throw new IllegalStateException("Illegal storage-type value '" + storageType + "'");
- }
+ return switch (storageType) {
+ case remote -> "remote";
+ case local -> "local";
+ case any -> "any";
+ };
}
private static NodeResources.Architecture architectureFromSlime(Inspector architecture) {
if ( ! architecture.valid()) return NodeResources.Architecture.getDefault(); // TODO: Remove this line after March 2022
- switch (architecture.asString()) {
- case "arm64" : return NodeResources.Architecture.arm64;
- case "x86_64" : return NodeResources.Architecture.x86_64;
- case "any" : return NodeResources.Architecture.any;
- default: throw new IllegalStateException("Illegal architecture value '" + architecture.asString() + "'");
- }
+ return switch (architecture.asString()) {
+ case "arm64" -> NodeResources.Architecture.arm64;
+ case "x86_64" -> NodeResources.Architecture.x86_64;
+ case "any" -> NodeResources.Architecture.any;
+ default -> throw new IllegalStateException("Illegal architecture value '" + architecture.asString() + "'");
+ };
}
private static String architectureToString(NodeResources.Architecture architecture) {
- switch (architecture) {
- case arm64 : return "arm64";
- case x86_64 : return "x86_64";
- case any : return "any";
- default: throw new IllegalStateException("Illegal architecture value '" + architecture + "'");
- }
+ return switch (architecture) {
+ case arm64 -> "arm64";
+ case x86_64 -> "x86_64";
+ case any -> "any";
+ };
+ }
+
+ private static NodeResources.GpuResources gpuResourcesFromSlime(Inspector gpu) {
+ if (!gpu.valid()) return NodeResources.GpuResources.getDefault();
+ return new NodeResources.GpuResources((int) gpu.field(gpuCountKey).asLong(),
+ gpu.field(gpuMemoryKey).asDouble());
}
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/FlavorConfigBuilder.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/FlavorConfigBuilder.java
index 4567d596c35..2bc5a0719d9 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/FlavorConfigBuilder.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/FlavorConfigBuilder.java
@@ -27,7 +27,7 @@ public class FlavorConfigBuilder {
double disk,
double bandwidth,
Flavor.Type type) {
- return addFlavor(flavorName, cpu, mem, disk, bandwidth, true, true, type, Architecture.x86_64);
+ return addFlavor(flavorName, cpu, mem, disk, bandwidth, true, true, type, Architecture.x86_64, 0, 0);
}
public FlavorsConfig.Flavor.Builder addFlavor(String flavorName,
@@ -37,7 +37,7 @@ public class FlavorConfigBuilder {
double bandwidth,
Flavor.Type type,
Architecture architecture) {
- return addFlavor(flavorName, cpu, mem, disk, bandwidth, true, true, type, architecture);
+ return addFlavor(flavorName, cpu, mem, disk, bandwidth, true, true, type, architecture, 0, 0);
}
public FlavorsConfig.Flavor.Builder addFlavor(String flavorName,
@@ -48,7 +48,9 @@ public class FlavorConfigBuilder {
boolean fastDisk,
boolean remoteStorage,
Flavor.Type type,
- Architecture architecture) {
+ Architecture architecture,
+ int gpuCount,
+ double gpuMemory) {
FlavorsConfig.Flavor.Builder flavor = new FlavorsConfig.Flavor.Builder();
flavor.name(flavorName);
flavor.minDiskAvailableGb(disk);
@@ -59,6 +61,8 @@ public class FlavorConfigBuilder {
flavor.fastDisk(fastDisk);
flavor.remoteStorage(remoteStorage);
flavor.architecture(architecture.name());
+ flavor.gpuCount(gpuCount);
+ flavor.gpuMemoryGb(gpuMemory);
builder.flavor(flavor);
return flavor;
}
@@ -84,6 +88,8 @@ public class FlavorConfigBuilder {
flavorConfigBuilder.addFlavor(flavorName, 4., 80., 100, 10, Flavor.Type.BARE_METAL);
else if (flavorName.equals("arm64"))
flavorConfigBuilder.addFlavor(flavorName,2., 30., 20., 3, Flavor.Type.BARE_METAL, Architecture.arm64);
+ else if (flavorName.equals("gpu"))
+ flavorConfigBuilder.addFlavor(flavorName,4, 16, 125, 10, true, false, Flavor.Type.BARE_METAL, Architecture.x86_64, 1, 16);
else
flavorConfigBuilder.addFlavor(flavorName, 1., 30., 20., 3, Flavor.Type.BARE_METAL);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java
index 2536d6b97ca..e8155234989 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java
@@ -59,7 +59,7 @@ import static org.junit.Assert.assertTrue;
*/
public class NodeSerializerTest {
- private final NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("default", "large", "ugccloud-container", "arm64");
+ private final NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("default", "large", "ugccloud-container", "arm64", "gpu");
private final NodeSerializer nodeSerializer = new NodeSerializer(nodeFlavors, 1000);
private final ManualClock clock = new ManualClock();
@@ -79,7 +79,8 @@ public class NodeSerializerTest {
public void reserved_node_serialization() {
Node node = createNode();
NodeResources requestedResources = new NodeResources(1.2, 3.4, 5.6, 7.8,
- DiskSpeed.any, StorageType.any, Architecture.arm64);
+ DiskSpeed.any, StorageType.any, Architecture.arm64,
+ new NodeResources.GpuResources(1, 16));
assertEquals(0, node.history().events().size());
node = node.allocate(ApplicationId.from(TenantName.from("myTenant"),