diff options
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 |
commit | 82cd17263d69b9310fd52172faac560495fa052a (patch) | |
tree | 846e52c66f5a46e685cbee78b9870522ac1650ae /controller-api | |
parent | bccf4389dd29f34c26be1c6c1387096321d79323 (diff) |
Ignore minor/micro versions in snapshots
Diffstat (limited to 'controller-api')
2 files changed, 12 insertions, 12 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 |