Skip to content

Commit 6ca076b

Browse files
authored
Fix ClusterBlock serialization and Close Index API logic after backport to 6.x (#37360)
This commit changes the versions in the serialization logic of ClusterBlock after the backport to 6.x of the Close Index API refactoring (#37359).
1 parent 87f9148 commit 6ca076b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

server/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static ClusterBlock readClusterBlock(StreamInput in) throws IOException {
138138
@Override
139139
public void readFrom(StreamInput in) throws IOException {
140140
id = in.readVInt();
141-
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
141+
if (in.getVersion().onOrAfter(Version.V_6_7_0)) {
142142
uuid = in.readOptionalString();
143143
} else {
144144
uuid = null;
@@ -159,7 +159,7 @@ public void readFrom(StreamInput in) throws IOException {
159159
@Override
160160
public void writeTo(StreamOutput out) throws IOException {
161161
out.writeVInt(id);
162-
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
162+
if (out.getVersion().onOrAfter(Version.V_6_7_0)) {
163163
out.writeOptionalString(uuid);
164164
}
165165
out.writeString(description);

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexStateService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static ClusterState addIndexClosedBlocks(final Index[] indices, final Map<Index,
225225

226226
// If the cluster is in a mixed version that does not support the shard close action,
227227
// we use the previous way to close indices and directly close them without sanity checks
228-
final boolean useDirectClose = currentState.nodes().getMinNodeVersion().before(Version.V_7_0_0);
228+
final boolean useDirectClose = currentState.nodes().getMinNodeVersion().before(Version.V_6_7_0);
229229

230230
final ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
231231
final RoutingTable.Builder routingTable = RoutingTable.builder(currentState.routingTable());

server/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testSerialization() throws Exception {
6565
public void testBwcSerialization() throws Exception {
6666
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
6767
// Generate a random cluster block in version < 7.0.0
68-
final Version version = randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_7_0_0));
68+
final Version version = randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_6_7_0));
6969
final ClusterBlock expected = randomClusterBlock(version);
7070
assertNull(expected.uuid());
7171

@@ -84,7 +84,7 @@ public void testBwcSerialization() throws Exception {
8484

8585
// Serialize to node in version < 7.0.0
8686
final BytesStreamOutput out = new BytesStreamOutput();
87-
out.setVersion(randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_7_0_0)));
87+
out.setVersion(randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_6_7_0)));
8888
expected.writeTo(out);
8989

9090
// Deserialize and check the cluster block
@@ -171,7 +171,7 @@ private ClusterBlock randomClusterBlock() {
171171
}
172172

173173
private ClusterBlock randomClusterBlock(final Version version) {
174-
final String uuid = (version.onOrAfter(Version.V_7_0_0) && randomBoolean()) ? UUIDs.randomBase64UUID() : null;
174+
final String uuid = (version.onOrAfter(Version.V_6_7_0) && randomBoolean()) ? UUIDs.randomBase64UUID() : null;
175175
final List<ClusterBlockLevel> levels = Arrays.asList(ClusterBlockLevel.values());
176176
return new ClusterBlock(randomInt(), uuid, "cluster block #" + randomInt(), randomBoolean(), randomBoolean(), randomBoolean(),
177177
randomFrom(RestStatus.values()), copyOf(randomSubsetOf(randomIntBetween(1, levels.size()), levels)));

0 commit comments

Comments
 (0)