Skip to content

Commit

Permalink
Autoscaling use adjusted total memory (#80528)
Browse files Browse the repository at this point in the history
The current capacity in use in autoscaling would use the full container
memory and not the adjusted total memory. ES sometimes responds with
`current_capacity` as `required_capacity` and the `current_capacity`
therefore need to use the adjusted capacity instead (since the
orchestration should add the memory reservation on top).

Relates #78750
  • Loading branch information
henningandersen committed Nov 9, 2021
1 parent 0db85b0 commit 74539e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private void retainAliveNodes(Set<DiscoveryNode> currentNodes) {
private void addNodeStats(ImmutableOpenMap.Builder<String, Long> builder, NodeStats nodeStats) {
// we might add nodes that already died here, but those will be removed on next cluster state update anyway and is only a small
// waste.
builder.put(nodeStats.getNode().getEphemeralId(), nodeStats.getOs().getMem().getTotal().getBytes());
builder.put(nodeStats.getNode().getEphemeralId(), nodeStats.getOs().getMem().getAdjustedTotal().getBytes());
}

public AutoscalingMemoryInfo snapshot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void assertMatchesResponse(Set<DiscoveryNode> nodes, NodesStatsResponse r
n -> {
assertThat(
service.snapshot().get(n),
equalTo(response.getNodesMap().get(n.getId()).getOs().getMem().getTotal().getBytes())
equalTo(response.getNodesMap().get(n.getId()).getOs().getMem().getAdjustedTotal().getBytes())
);
}
);
Expand All @@ -347,7 +347,7 @@ private static NodeStats statsForNode(DiscoveryNode node, long memory) {
OsStats osStats = new OsStats(
randomNonNegativeLong(),
new OsStats.Cpu(randomShort(), null),
new OsStats.Mem(memory, memory, randomLongBetween(0, memory)),
new OsStats.Mem(memory, randomLongBetween(0, memory), randomLongBetween(0, memory)),
new OsStats.Swap(randomNonNegativeLong(), randomNonNegativeLong()),
null
);
Expand Down

0 comments on commit 74539e0

Please sign in to comment.