From 95f64588918e2adb7c6627624db60bb44710cc02 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Wed, 27 Nov 2024 09:58:48 +0100 Subject: [PATCH] Simplify allocation error --- .../com/yahoo/vespa/hosted/provision/autoscale/Limits.java | 5 +++-- .../provision/provisioning/NodeRepositoryProvisioner.java | 2 +- .../provision/provisioning/DynamicProvisioningTest.java | 2 +- .../provision/provisioning/VirtualNodeProvisioningTest.java | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Limits.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Limits.java index 865682516009..ce20e5d94d58 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Limits.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Limits.java @@ -1,11 +1,11 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.autoscale; -import com.yahoo.config.provision.IntRange; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Capacity; import com.yahoo.config.provision.ClusterResources; import com.yahoo.config.provision.ClusterSpec; +import com.yahoo.config.provision.IntRange; import com.yahoo.config.provision.NodeResources; import com.yahoo.vespa.hosted.provision.NodeRepository; import com.yahoo.vespa.hosted.provision.applications.Cluster; @@ -80,7 +80,8 @@ private double between(double min, double max, double value) { @Override public String toString() { if (isEmpty()) return "no limits"; - return "limits: from " + min + " to " + max + ( groupSize.isEmpty() ? "" : " with group size " + groupSize); + return (min.equals(max) ? "resources " + min : "limits from " + min + " to " + max) + + (groupSize.isEmpty() ? "" : ", group size " + groupSize); } public static Limits of(Cluster cluster) { 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 d44e7e11799b..816e72b79d61 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 @@ -278,7 +278,7 @@ private static NodeResources requireCompatibleResources(NodeResources nodeResour } private IllegalArgumentException newNoAllocationPossible(ClusterSpec spec, Limits limits) { - StringBuilder message = new StringBuilder("No allocation possible within ").append(limits); + StringBuilder message = new StringBuilder("No allocation possible with ").append(limits); if (nodeRepository.exclusivity().allocation(spec) && findNearestNodeResources(limits).isPresent()) message.append(". Nearest allowed node resources: ").append(findNearestNodeResources(limits).get()); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java index 78a34326949e..bdcfa0f2f333 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java @@ -311,7 +311,7 @@ public void capacity_is_in_advertised_amounts() { } catch (IllegalArgumentException e) { // Success - String expected = "No allocation possible within limits"; + String expected = "No allocation possible with limits"; assertEquals(expected, e.getMessage().substring(0, expected.length())); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/VirtualNodeProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/VirtualNodeProvisioningTest.java index 9a6fdedb213f..fbed7020fb6a 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/VirtualNodeProvisioningTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/VirtualNodeProvisioningTest.java @@ -3,6 +3,7 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ApplicationMutex; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.ApplicationTransaction; import com.yahoo.config.provision.Capacity; @@ -15,7 +16,6 @@ import com.yahoo.config.provision.NodeAllocationException; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.NodeType; -import com.yahoo.config.provision.ApplicationMutex; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.TenantName; @@ -548,7 +548,7 @@ public void too_few_real_resources_causes_failure() { new ClusterResources(4, 1, resources))); } catch (IllegalArgumentException e) { - assertEquals("No allocation possible within limits: " + + assertEquals("No allocation possible with limits " + "from 2 nodes with [vcpu: 1.0, memory: 5.0 Gb, disk: 10.0 Gb, bandwidth: 1.0 Gbps, architecture: any] " + "to 4 nodes with [vcpu: 1.0, memory: 5.0 Gb, disk: 10.0 Gb, bandwidth: 1.0 Gbps, architecture: any]", e.getMessage()); @@ -572,7 +572,7 @@ public void exclusive_resources_not_matching_host_causes_failure() { new ClusterResources(4, 1, resources))); } catch (IllegalArgumentException e) { - assertEquals("No allocation possible within limits: " + + assertEquals("No allocation possible with limits " + "from 2 nodes with [vcpu: 20.0, memory: 37.0 Gb, disk: 100.0 Gb, bandwidth: 1.0 Gbps, architecture: any] " + "to 4 nodes with [vcpu: 20.0, memory: 37.0 Gb, disk: 100.0 Gb, bandwidth: 1.0 Gbps, architecture: any]. " + "Nearest allowed node resources: [vcpu: 20.0, memory: 40.0 Gb, disk: 100.0 Gb, bandwidth: 1.0 Gbps, storage type: remote, architecture: any]",