Skip to content

Commit 101bd2d

Browse files
committed
[Test] Allow allocation in mixed cluster
The RunningSnapshotIT upgrade test adds shutdown marker to all nodes and removed them once all nodes are upgraded. If an index gets created in a mixed cluster, for example by ILM or deprecation messages, the index cannot be allocated because all nodes are shutting down. Since the cluster ready check between node upgrades expects a yellow cluster, the unassigned index prevents the ready check to succeed and eventually timeout. This PR fixes it by removing shutdown marker for the 1st upgrade node to allow it hosting new indices. Resolves: #129644 Resolves: #129645 Resolves: #129646
1 parent 92b32b5 commit 101bd2d

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

muted-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,6 @@ tests:
571571
- class: org.elasticsearch.server.cli.MachineDependentHeapTests
572572
method: testMlOnlyOptions
573573
issue: https://github.com/elastic/elasticsearch/issues/129236
574-
- class: org.elasticsearch.upgrades.RunningSnapshotIT
575-
method: testRunningSnapshotCompleteAfterUpgrade {upgradedNodes=1}
576-
issue: https://github.com/elastic/elasticsearch/issues/129644
577-
- class: org.elasticsearch.upgrades.RunningSnapshotIT
578-
method: testRunningSnapshotCompleteAfterUpgrade {upgradedNodes=2}
579-
issue: https://github.com/elastic/elasticsearch/issues/129645
580-
- class: org.elasticsearch.upgrades.RunningSnapshotIT
581-
method: testRunningSnapshotCompleteAfterUpgrade {upgradedNodes=3}
582-
issue: https://github.com/elastic/elasticsearch/issues/129646
583574
- class: org.elasticsearch.test.apmintegration.TracesApmIT
584575
method: testApmIntegration
585576
issue: https://github.com/elastic/elasticsearch/issues/129651

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/RunningSnapshotIT.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
import java.io.IOException;
2020
import java.util.Collection;
21+
import java.util.Map;
22+
import java.util.stream.Collectors;
2123

24+
import static org.elasticsearch.client.RestClient.IGNORE_RESPONSE_CODES_PARAM;
2225
import static org.elasticsearch.upgrades.SnapshotBasedRecoveryIT.indexDocs;
2326
import static org.hamcrest.Matchers.empty;
2427
import static org.hamcrest.Matchers.equalTo;
@@ -34,7 +37,10 @@ public void testRunningSnapshotCompleteAfterUpgrade() throws Exception {
3437
final String indexName = "index";
3538
final String repositoryName = "repo";
3639
final String snapshotName = "snapshot";
37-
final var nodeIds = getNodesInfo(client()).keySet();
40+
final Map<String, Map<?, ?>> nodesInfo = getNodesInfo(client());
41+
final var nodeIdToBuildHashes = nodesInfo.entrySet()
42+
.stream()
43+
.collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, entry -> entry.getValue().get("build_hash").toString()));
3844

3945
if (isOldCluster()) {
4046
registerRepository(repositoryName, "fs", randomBoolean(), Settings.builder().put("location", "backup").build());
@@ -46,16 +52,27 @@ public void testRunningSnapshotCompleteAfterUpgrade() throws Exception {
4652
}
4753
flush(indexName, true);
4854
// Signal shutdown to prevent snapshot from being completed
49-
putShutdownMetadata(nodeIds);
55+
putShutdownMetadata(nodeIdToBuildHashes.keySet());
5056
createSnapshot(repositoryName, snapshotName, false);
5157
assertRunningSnapshot(repositoryName, snapshotName);
5258
} else {
5359
if (isUpgradedCluster()) {
54-
deleteShutdownMetadata(nodeIds);
55-
assertNoShutdownMetadata(nodeIds);
60+
deleteShutdownMetadata(nodeIdToBuildHashes.keySet());
61+
assertNoShutdownMetadata(nodeIdToBuildHashes.keySet());
5662
ensureGreen(indexName);
5763
assertBusy(() -> assertCompletedSnapshot(repositoryName, snapshotName));
5864
} else {
65+
final var buildHashToNodeIds = nodeIdToBuildHashes.entrySet()
66+
.stream()
67+
.collect(Collectors.groupingBy(Map.Entry::getValue, Collectors.mapping(Map.Entry::getKey, Collectors.toSet())));
68+
if (isFirstMixedCluster()) {
69+
final var upgradedNodeIds = buildHashToNodeIds.values()
70+
.stream()
71+
.filter(strings -> strings.size() == 1)
72+
.findFirst()
73+
.orElseThrow(() -> new AssertionError("expect one upgraded node, but got " + buildHashToNodeIds));
74+
deleteShutdownMetadata(upgradedNodeIds);
75+
}
5976
assertRunningSnapshot(repositoryName, snapshotName);
6077
}
6178
}
@@ -76,6 +93,7 @@ private void putShutdownMetadata(Collection<String> nodeIds) throws IOException
7693
private void deleteShutdownMetadata(Collection<String> nodeIds) throws IOException {
7794
for (String nodeId : nodeIds) {
7895
final Request request = new Request("DELETE", "/_nodes/" + nodeId + "/shutdown");
96+
request.addParameter(IGNORE_RESPONSE_CODES_PARAM, "404");
7997
client().performRequest(request);
8098
}
8199
}

0 commit comments

Comments
 (0)