Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
976b616
Add shard explain info to ReactiveReason about assigned and unassigne…
arteam Jul 18, 2022
e7bd66f
Work on assigned shards
arteam Jul 22, 2022
d04ec8d
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Jul 24, 2022
b58730b
Add assertions for assigned allocation decision
arteam Jul 25, 2022
d08df0f
Collect shards instead of shard ids for explaining
arteam Jul 25, 2022
5399b93
Inline shardAllocationDecisions
arteam Jul 25, 2022
a4c27c1
Update docs/changelog/88590.yaml
arteam Jul 25, 2022
83abc1b
Mutate allocation decisions
arteam Jul 25, 2022
f1a171f
Merge remote-tracking branch 'origin/shard_allocation_explain' into s…
arteam Jul 25, 2022
ef0ccd1
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Jul 26, 2022
5f8dee3
Add @Nullable for decisions
arteam Jul 26, 2022
b261f55
Sort ShardRouting externally, don't use Comparable
arteam Jul 26, 2022
bd50e10
Add equals&hashCode tests for ShardAllocationDecision
arteam Jul 26, 2022
186b346
Run spotless
arteam Jul 26, 2022
141fe5e
Add missed license
arteam Jul 26, 2022
3fb069e
Use correct license
arteam Jul 26, 2022
7e930c6
Test -> Tests
arteam Jul 26, 2022
010216d
Inject AllocationService via AutoscalingDeciderContext
arteam Jul 26, 2022
7f9092e
Remove empty line
arteam Jul 26, 2022
5e947b1
Add reference check for equals in ShardAllocationDecision
arteam Jul 26, 2022
ae0fdbb
Use a terse form of enabling debug decision
arteam Jul 26, 2022
448d2f1
Verify that we pick up the first assigned and unassigned shards
arteam Jul 26, 2022
33e2355
Use correct Mockito assertions
arteam Jul 27, 2022
e651a58
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Jul 27, 2022
70699d0
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Jul 28, 2022
2c70547
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Aug 2, 2022
b975e43
Check allowedDecision
arteam Aug 4, 2022
d4e9428
Check label and explanation
arteam Aug 4, 2022
287d4fa
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Aug 4, 2022
584dacb
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Aug 9, 2022
c9b6d2d
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Aug 10, 2022
ef017a7
Propagate NodeAllocationResult to ShardSize
arteam Aug 10, 2022
646cfbe
Remove autoscaling service
arteam Aug 15, 2022
6a2638c
Replace ShardAllocationDecision to node allocation results
arteam Aug 15, 2022
7b037a3
Store nodeAllocationResults
arteam Aug 15, 2022
d32e51b
Run spotless
arteam Aug 15, 2022
9982916
Adjust the scaleUp test
arteam Aug 15, 2022
1306962
Fix ReactiveReason
arteam Aug 15, 2022
b6fb744
Remove unnecessary changes related to ShardAllocationDecision
arteam Aug 15, 2022
8f7aab4
Remove remained uses of allocationService
arteam Aug 15, 2022
9ab4971
Run spotless
arteam Aug 15, 2022
9c907f9
Inline builder
arteam Aug 15, 2022
ce005c4
Fix ReactiveStorageDeciderDecisionTests
arteam Aug 15, 2022
bbe33c4
NodeAllocationResult should have equals&hashCode
arteam Aug 15, 2022
dd02cbe
Remove allocationService from TransportGetAutoscalingCapacityAction
arteam Aug 15, 2022
817165c
Bring back shardIds
arteam Aug 15, 2022
05f4e24
Remove unused import
arteam Aug 15, 2022
8f6836a
Remove changed comment by mistake
arteam Aug 15, 2022
6a32fac
Don't verify the whole ShardSize
arteam Aug 15, 2022
2b23c47
Remove unrelated comments changes
arteam Aug 16, 2022
4f5b14f
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Aug 16, 2022
47d081a
unmovableShardNodeAllocationResults can be a list
arteam Aug 16, 2022
e49c7ac
Make sure we pick up the 1st shard by shardId for node allocation res…
arteam Aug 16, 2022
d99caf9
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Aug 17, 2022
47bfc07
Use flatMap for checking decisions
arteam Aug 17, 2022
249c903
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 5, 2022
b6e1428
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 8, 2022
6641777
Unassigned allocation results are introduced in 8.5.0
arteam Sep 8, 2022
1faa877
Rename DecisionAllocationResults to ShardAllocationResults
arteam Sep 8, 2022
cf607f3
ShardsSize -> ShardsAllocationResults
arteam Sep 8, 2022
ede35d7
Return empty node allocation results
arteam Sep 8, 2022
9e67400
Verify that decisions get serialized
arteam Sep 9, 2022
a992b12
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 9, 2022
5b4c2fc
Revert "Inline builder"
arteam Sep 9, 2022
bb650ad
Revert "Fix ReactiveReason"
arteam Sep 9, 2022
f5619a2
Remove accidential newline
arteam Sep 9, 2022
9c56d27
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 9, 2022
0f29489
Don't double write assigned and unassigned results
arteam Sep 9, 2022
6ca1549
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 12, 2022
283dbd5
Don't use Optionals for flow control
arteam Sep 12, 2022
5488f95
Calculate additional can_remain and can_allocate decisions
arteam Sep 12, 2022
de6c17b
Use ShardNodeAllocationResults
arteam Sep 12, 2022
d4b6f3e
Check can_allocate decisions on other nodes in the tier
arteam Sep 12, 2022
5d7b3fd
Remove the decision flag, use Optional
arteam Sep 12, 2022
8260d6e
Remove mixing up can_remain and can_allocate decisions
arteam Sep 13, 2022
a58e4e6
Use NodeDecision to represent both can_remain and can_allocate decisions
arteam Sep 13, 2022
5df0783
Add allocation decisions for other hot nodes
arteam Sep 13, 2022
004b3f4
Add can_remain decisions for unallocated shards
arteam Sep 13, 2022
7363356
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 14, 2022
0ed8a62
Remove redundant branch
arteam Sep 14, 2022
b6f07a5
More random decisions
arteam Sep 14, 2022
592a7eb
Decision isn't optional
arteam Sep 14, 2022
5e95767
Add a wire test for NodeDecisions
arteam Sep 14, 2022
ca59b7a
nodeAllocationResults -> nodeDecisions
arteam Sep 14, 2022
2347eb5
Serialize node_decisions even if they are null
arteam Sep 14, 2022
4483af5
Use instanceof pattern matching
arteam Sep 14, 2022
4123b77
Run spotless
arteam Sep 14, 2022
e231d69
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 14, 2022
ffae505
Add diskOnly decisions for resizeOnly case
arteam Sep 14, 2022
863707f
Use nodeDecisions everywhere instead of allocation results
arteam Sep 14, 2022
b3be8b1
Remove unnecessary equals&hashCode from NodeAllocationResult
arteam Sep 14, 2022
8c0e48c
Add missed license
arteam Sep 14, 2022
96de20c
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 15, 2022
772fc0c
Mutate nodeDecisions
arteam Sep 15, 2022
753a683
Use shardNodeDecisions
arteam Sep 15, 2022
3908deb
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 19, 2022
00dfdaa
Move NodeDecision to `autoscaling.storage`
arteam Sep 19, 2022
17724c1
Correctly concatenate assigned and unassigned node decisions
arteam Sep 19, 2022
648fe7c
Remove unused wrapping for the resize case
arteam Sep 19, 2022
2f67943
Strength the check for the single NO decisions
arteam Sep 19, 2022
3446621
Fix license for NodeDecision
arteam Sep 19, 2022
ea743a9
Limit the amount of decisions
arteam Sep 19, 2022
a603712
Store all shard node decisions
arteam Sep 20, 2022
bf46d0f
Merge branch 'main' into shard_allocation_explain
arteam Sep 22, 2022
0345560
Add missed license for NodeDecisions
arteam Sep 22, 2022
f4df208
Run spotless
arteam Sep 22, 2022
e79e5b1
NodeDecisions should be package-private
arteam Sep 22, 2022
64e42e8
Fix tests for ReactiveReasonTests
arteam Sep 22, 2022
350dfb1
Fix merging of node decisions
arteam Sep 22, 2022
3d2d027
Run spotless
arteam Sep 22, 2022
4228300
Adjust new canAllocate and canRemain assertions
arteam Sep 22, 2022
6ffafe0
Don't merge node decisions
arteam Sep 22, 2022
425f227
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 23, 2022
a15931d
Add node decisions tests
arteam Sep 23, 2022
a2103b0
Add additional checks about node decisions
arteam Sep 23, 2022
a5891ac
Add missed licenses
arteam Sep 23, 2022
684c076
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 23, 2022
33ab884
Use shorter versions of toMap
arteam Sep 23, 2022
7a73d7a
Update UNASSIGNED_NODE_DECISIONS_OUTPUT_VERSION to 8.6.0
arteam Sep 23, 2022
43d9968
Update x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpac…
arteam Sep 23, 2022
4a0aa8b
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Sep 27, 2022
7f74739
Move the limiting part to shard decisions map
arteam Sep 27, 2022
3776644
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Oct 5, 2022
14def6a
Remove unnecessary limit
arteam Oct 5, 2022
2b00b1d
Return sorted map of shards
arteam Oct 5, 2022
a0e4d60
Return all node decisions not only disk only
arteam Oct 5, 2022
0dfb815
Make sure there are no collisions for random node decisions
arteam Oct 5, 2022
20913c6
Enable allocation decisions
arteam Oct 5, 2022
5ddff3f
Check debug decisions for can remain decisions
arteam Oct 5, 2022
73b6daf
Add assertions for debug can_allocate decisions
arteam Oct 5, 2022
8aff715
Use assertDebugNoDecision also for can_remain decisions
arteam Oct 5, 2022
fcc08c5
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Oct 5, 2022
e6af2c3
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Oct 10, 2022
e55454a
Merge branch 'main' into shard_allocation_explain
elasticmachine Oct 18, 2022
59e947c
Merge branch 'main' into shard_allocation_explain
elasticmachine Nov 3, 2022
e062a02
Merge branch 'main' into shard_allocation_explain
elasticmachine Nov 23, 2022
c888368
Apply patch: https://github.com/elastic/elasticsearch/pull/88590/file…
arteam Nov 24, 2022
13e3caf
Merge branch 'main' into shard_allocation_explain
elasticmachine Jan 4, 2023
3a48c09
Merge branch 'main' into shard_allocation_explain
elasticmachine Jan 13, 2023
a6bf4d8
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Jan 27, 2023
7eec2fd
Use getTransportVersion
arteam Jan 27, 2023
072215e
Check all can_allocate and can_remain decisions
arteam Jan 28, 2023
be62506
Update javadoc for ShardNodeDecisions
arteam Jan 28, 2023
a66daf5
Allow to serialize multiple deciders
arteam Jan 30, 2023
5a47093
We can have only one remainDecision at most
arteam Jan 30, 2023
4d1ef65
Fix the docs line length
arteam Jan 30, 2023
da67447
Fix compilation issues in autoscaling integration tests
arteam Jan 30, 2023
2752444
Merge branch 'main' into shard_allocation_explain
elasticmachine Feb 8, 2023
bb33969
Merge branch 'main' into shard_allocation_explain
elasticmachine Feb 14, 2023
8da8f25
Add check for empty canAllocateDecisions
arteam Feb 14, 2023
6a1f179
Remove redundant semicolon
arteam Feb 14, 2023
e9d5440
Merge branch 'main' into shard_allocation_explain
elasticmachine Feb 28, 2023
7f857e5
Merge branch 'main' into shard_allocation_explain
elasticmachine Mar 6, 2023
1364fd8
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Apr 12, 2023
9bf9e22
Fix merge conflicts
arteam Apr 12, 2023
d1c1a5c
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Apr 12, 2023
f116c59
Merge branch 'shard_allocation_explain' of github.com:arteam/elastics…
arteam Apr 12, 2023
b1bff16
Merge remote-tracking branch 'origin/main' into shard_allocation_explain
arteam Apr 27, 2023
04624e5
Make sure decisions are random
arteam Apr 27, 2023
626f4d3
Test serialization of multi decisions
arteam Apr 27, 2023
6589974
Check the size of canAllocateDecisions
arteam Apr 27, 2023
448c56d
Omit canRemainDecision if it's null
arteam Apr 27, 2023
0d8b5de
Test that we don't output can_remain_decision in JSON
arteam Apr 27, 2023
6b6c30a
Bump the transport version
arteam Apr 27, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/88590.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 88590
summary: Add shard explain info to `ReactiveReason` about unassigned shards
area: Autoscaling
type: enhancement
issues:
- 85243
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
import org.elasticsearch.cluster.routing.allocation.DataTier;
import org.elasticsearch.cluster.routing.allocation.decider.Decision;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Tuple;
Expand All @@ -39,6 +40,8 @@

import static org.elasticsearch.index.store.Store.INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.xpack.autoscaling.storage.ReactiveStorageDeciderService.AllocationState.MAX_AMOUNT_OF_SHARD_DECISIONS;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
Expand Down Expand Up @@ -105,6 +108,30 @@ public void testScaleUp() throws InterruptedException {
response.results().get(policyName).requiredCapacity().node().storage().getBytes(),
equalTo(maxShardSize + ReactiveStorageDeciderService.NODE_DISK_OVERHEAD + LOW_WATERMARK_BYTES)
);
var reactiveReason = (ReactiveStorageDeciderService.ReactiveReason) response.results()
.get(policyName)
.results()
.get("reactive_storage")
.reason();
assertEquals(
reactiveReason.assignedShardIds().stream().limit(MAX_AMOUNT_OF_SHARD_DECISIONS).collect(Collectors.toSet()),
reactiveReason.assignedNodeDecisions().keySet()
);
NodeDecision canRemainNodeDecision = reactiveReason.assignedNodeDecisions()
.get(reactiveReason.assignedShardIds().first())
.canRemainDecision();
Decision decision = canRemainNodeDecision.decision()
.getDecisions()
.stream()
.filter(d -> d.type() == Decision.Type.NO)
.findFirst()
.orElseThrow(() -> new IllegalStateException("Unable to find NO can_remain decision"));
assertEquals(Decision.Type.NO, decision.type());
assertEquals("disk_threshold", decision.label());
assertThat(
decision.getExplanation(),
startsWith("the shard cannot remain on this node because it is above the high watermark cluster setting")
);
}

public void testScaleFromEmptyWarmMove() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.autoscaling.storage;

import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.allocation.decider.Decision;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.Objects;

import static org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision.discoveryNodeToXContent;

class NodeDecision implements ToXContentObject, Writeable {

private final DiscoveryNode node;
private final Decision decision;

NodeDecision(DiscoveryNode node, Decision decision) {
this.node = node;
this.decision = decision;
}

NodeDecision(StreamInput in) throws IOException {
node = new DiscoveryNode(in);
decision = Decision.readFrom(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
node.writeTo(out);
decision.writeTo(out);
}

DiscoveryNode node() {
return node;
}

Decision decision() {
return decision;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
return o instanceof NodeDecision that && Objects.equals(node, that.node) && Objects.equals(decision, that.decision);
}

@Override
public int hashCode() {
return Objects.hash(node, decision);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
discoveryNodeToXContent(node, false, builder);
{
builder.startArray("deciders");
decision.toXContent(builder, params);
builder.endArray();
}
builder.endObject();
return builder;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.autoscaling.storage;

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.List;
import java.util.Objects;

class NodeDecisions implements ToXContentObject, Writeable {

private final List<NodeDecision> canAllocateDecisions;
@Nullable
private final NodeDecision canRemainDecision;

NodeDecisions(List<NodeDecision> canAllocateDecisions, @Nullable NodeDecision canRemainDecision) {
this.canAllocateDecisions = canAllocateDecisions;
this.canRemainDecision = canRemainDecision;
}

NodeDecisions(StreamInput in) throws IOException {
canAllocateDecisions = in.readList(NodeDecision::new);
canRemainDecision = in.readOptionalWriteable(NodeDecision::new);
}

List<NodeDecision> canAllocateDecisions() {
return canAllocateDecisions;
}

@Nullable
NodeDecision canRemainDecision() {
return canRemainDecision;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeList(canAllocateDecisions);
out.writeOptionalWriteable(canRemainDecision);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.xContentList("can_allocate_decisions", canAllocateDecisions);
if (canRemainDecision != null) {
builder.field("can_remain_decision", canRemainDecision);
}
builder.endObject();
return null;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NodeDecisions that = (NodeDecisions) o;
return Objects.equals(canAllocateDecisions, that.canAllocateDecisions) && Objects.equals(canRemainDecision, that.canRemainDecision);
}

@Override
public int hashCode() {
return Objects.hash(canAllocateDecisions, canRemainDecision);
}
}
Loading