aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@yahooinc.com>2023-03-14 13:46:25 +0100
committerØyvind Grønnesby <oyving@yahooinc.com>2023-03-14 13:46:25 +0100
commit82cd17263d69b9310fd52172faac560495fa052a (patch)
tree846e52c66f5a46e685cbee78b9870522ac1650ae
parentbccf4389dd29f34c26be1c6c1387096321d79323 (diff)
Ignore minor/micro versions in snapshots
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java4
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceSnapshot.java20
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java6
3 files changed, 15 insertions, 15 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java
index c1d210e990d..5c9a5817dff 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java
@@ -79,7 +79,7 @@ public class ResourceDatabaseClientMock implements ResourceDatabaseClient {
a.getZoneId(),
plan,
a.resources().architecture(),
- a.getVersion().getMajor(),
+ a.getMajorVersion(),
BigDecimal.valueOf(a.resources().vcpu()).multiply(d),
BigDecimal.valueOf(a.resources().memoryGb()).multiply(d),
BigDecimal.valueOf(a.resources().diskGb()).multiply(d)
@@ -114,7 +114,7 @@ public class ResourceDatabaseClientMock implements ResourceDatabaseClient {
.filter(snapshot -> snapshot.getTimestamp().isBefore(Instant.ofEpochMilli(end)))
.filter(snapshot -> snapshot.getApplicationId().tenant().equals(tenantName))
.collect(Collectors.groupingBy(
- usage -> Objects.hash(usage.getApplicationId(), usage.getZoneId(), tenantPlan.id().value(), usage.resources().architecture(), usage.getVersion().getMajor())
+ usage -> Objects.hash(usage.getApplicationId(), usage.getZoneId(), tenantPlan.id().value(), usage.resources().architecture(), usage.getMajorVersion())
))
.values().stream()
.map(snapshots -> resourceUsageFromSnapshots(tenantPlan, snapshots))
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceSnapshot.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceSnapshot.java
index 778e288f316..b3a91767465 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceSnapshot.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceSnapshot.java
@@ -31,18 +31,18 @@ public class ResourceSnapshot {
private final NodeResources resources;
private final Instant timestamp;
private final ZoneId zoneId;
- private final Version version;
+ private final int majorVersion;
- public ResourceSnapshot(ApplicationId applicationId, NodeResources resources, Instant timestamp, ZoneId zoneId, Version version) {
+ public ResourceSnapshot(ApplicationId applicationId, NodeResources resources, Instant timestamp, ZoneId zoneId, int majorVersion) {
this.applicationId = applicationId;
this.resources = resources;
this.timestamp = timestamp;
this.zoneId = zoneId;
- this.version = version;
+ this.majorVersion = majorVersion;
}
public static ResourceSnapshot from(ApplicationId applicationId, int nodes, NodeResources resources, Instant timestamp, ZoneId zoneId) {
- return new ResourceSnapshot(applicationId, resources.multipliedBy(nodes), timestamp, zoneId, Version.emptyVersion);
+ return new ResourceSnapshot(applicationId, resources.multipliedBy(nodes), timestamp, zoneId, 0);
}
public static ResourceSnapshot from(List<Node> nodes, Instant timestamp, ZoneId zoneId) {
@@ -51,8 +51,8 @@ public class ResourceSnapshot {
.map(node -> node.owner().get())
.collect(Collectors.toSet());
- Set<Version> versions = nodes.stream()
- .map(Node::currentVersion)
+ Set<Integer> versions = nodes.stream()
+ .map(n -> n.wantedVersion().getMajor())
.collect(Collectors.toSet());
if (applicationIds.size() != 1) throw new IllegalArgumentException("List of nodes can only represent one application");
@@ -81,8 +81,8 @@ public class ResourceSnapshot {
return zoneId;
}
- public Version getVersion() {
- return version;
+ public int getMajorVersion() {
+ return majorVersion;
}
@Override
@@ -95,12 +95,12 @@ public class ResourceSnapshot {
this.resources.equals(other.resources) &&
this.timestamp.equals(other.timestamp) &&
this.zoneId.equals(other.zoneId) &&
- this.version.equals(other.version);
+ this.majorVersion == other.majorVersion;
}
@Override
public int hashCode(){
- return Objects.hash(applicationId, resources, timestamp, zoneId, version);
+ return Objects.hash(applicationId, resources, timestamp, zoneId, majorVersion);
}
/* This function does pretty much the same thing as NodeResources::add, but it allows adding resources
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java
index 0976eedee23..3f20c2eac8f 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java
@@ -286,17 +286,17 @@ public class ResourceMeterMaintainer extends ControllerMaintainer {
));
}
- private Collector<Node, ?, Map<NodeResources.Architecture, Map<Version, ResourceSnapshot>>> groupSnapshotsByArchitectureAndMajorVersion(ZoneId zoneId) {
+ private Collector<Node, ?, Map<NodeResources.Architecture, Map<Integer, ResourceSnapshot>>> groupSnapshotsByArchitectureAndMajorVersion(ZoneId zoneId) {
return Collectors.groupingBy(
(Node node) -> node.resources().architecture(),
Collectors.collectingAndThen(
Collectors.groupingBy(
- (Node node) -> node.currentVersion(),
+ (Node node) -> node.wantedVersion().getMajor(),
Collectors.toList()),
convertNodeListToResourceSnapshot(zoneId)));
}
- private Function<Map<Version, List<Node>>, Map<Version, ResourceSnapshot>> convertNodeListToResourceSnapshot(ZoneId zoneId) {
+ private Function<Map<Integer, List<Node>>, Map<Integer, ResourceSnapshot>> convertNodeListToResourceSnapshot(ZoneId zoneId) {
return nodesByMajor -> {
return nodesByMajor.entrySet().stream()
.collect(Collectors.toMap(