Skip to content

Commit 77cff55

Browse files
authored
[Remove] LegacyESVersion.V_7_4_* and V_7_5_* constants (#4704)
Removes all usages of LegacyESVersion.V_7_4_ and LegacyESVersion.V_7_5 version constants along with ancient API logic. Signed-off-by: Nicholas Walter Knize <[email protected]>
1 parent fe3994c commit 77cff55

File tree

38 files changed

+64
-712
lines changed

38 files changed

+64
-712
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
8787
- Remove LegacyESVersion.V_7_0_* and V_7_1_* Constants ([#2768](https://https://github.com/opensearch-project/OpenSearch/pull/2768))
8888
- Remove LegacyESVersion.V_7_2_ and V_7_3_ Constants ([#4702](https://github.com/opensearch-project/OpenSearch/pull/4702))
8989
- Always auto release the flood stage block ([#4703](https://github.com/opensearch-project/OpenSearch/pull/4703))
90+
- Remove LegacyESVersion.V_7_4_ and V_7_5_ Constants ([#4704](https://github.com/opensearch-project/OpenSearch/pull/4704))
9091

9192
### Fixed
9293

qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/IndexingIT.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,7 @@ public void testAutoIdWithOpTypeCreate() throws IOException {
181181
}
182182
}
183183

184-
if (minNodeVersion.before(LegacyESVersion.V_7_5_0)) {
185-
ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(bulk));
186-
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
187-
assertThat(e.getMessage(),
188-
// if request goes to 7.5+ node
189-
either(containsString("optype create not supported for indexing requests without explicit id until"))
190-
// if request goes to < 7.5 node
191-
.or(containsString("an id must be provided if version type or value are set")
192-
));
193-
} else {
194-
client().performRequest(bulk);
195-
}
184+
client().performRequest(bulk);
196185
break;
197186
case UPGRADED:
198187
client().performRequest(bulk);

server/src/internalClusterTest/java/org/opensearch/snapshots/DedicatedClusterSnapshotRestoreIT.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
import org.opensearch.Version;
3939
import org.opensearch.action.ActionFuture;
40-
import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
4140
import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
4241
import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
4342
import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
@@ -47,7 +46,6 @@
4746
import org.opensearch.action.admin.indices.stats.ShardStats;
4847
import org.opensearch.action.index.IndexRequestBuilder;
4948
import org.opensearch.action.support.ActiveShardCount;
50-
import org.opensearch.action.support.PlainActionFuture;
5149
import org.opensearch.action.support.master.AcknowledgedResponse;
5250
import org.opensearch.client.Client;
5351
import org.opensearch.client.node.NodeClient;
@@ -1386,44 +1384,6 @@ public void testPartialSnapshotAllShardsMissing() throws Exception {
13861384
assertThat(createSnapshotResponse.getSnapshotInfo().state(), is(SnapshotState.PARTIAL));
13871385
}
13881386

1389-
/**
1390-
* Tests for the legacy snapshot path that is normally executed if the cluster contains any nodes older than
1391-
* {@link SnapshotsService#NO_REPO_INITIALIZE_VERSION}.
1392-
* Makes sure that blocking as well as non-blocking snapshot create paths execute cleanly as well as that error handling works out
1393-
* correctly by testing a snapshot name collision.
1394-
*/
1395-
public void testCreateSnapshotLegacyPath() throws Exception {
1396-
final String clusterManagerNode = internalCluster().startClusterManagerOnlyNode();
1397-
internalCluster().startDataOnlyNode();
1398-
final String repoName = "test-repo";
1399-
createRepository(repoName, "fs");
1400-
createIndex("some-index");
1401-
1402-
final SnapshotsService snapshotsService = internalCluster().getClusterManagerNodeInstance(SnapshotsService.class);
1403-
final Snapshot snapshot1 = PlainActionFuture.get(
1404-
f -> snapshotsService.createSnapshotLegacy(new CreateSnapshotRequest(repoName, "snap-1"), f)
1405-
);
1406-
awaitNoMoreRunningOperations(clusterManagerNode);
1407-
1408-
final InvalidSnapshotNameException sne = expectThrows(
1409-
InvalidSnapshotNameException.class,
1410-
() -> PlainActionFuture.<SnapshotInfo, Exception>get(
1411-
f -> snapshotsService.executeSnapshotLegacy(new CreateSnapshotRequest(repoName, snapshot1.getSnapshotId().getName()), f)
1412-
)
1413-
);
1414-
1415-
assertThat(sne.getMessage(), containsString("snapshot with the same name already exists"));
1416-
final SnapshotInfo snapshot2 = PlainActionFuture.get(
1417-
f -> snapshotsService.executeSnapshotLegacy(new CreateSnapshotRequest(repoName, "snap-2"), f)
1418-
);
1419-
assertThat(snapshot2.state(), is(SnapshotState.SUCCESS));
1420-
1421-
final SnapshotInfo snapshot3 = PlainActionFuture.get(
1422-
f -> snapshotsService.executeSnapshotLegacy(new CreateSnapshotRequest(repoName, "snap-3").indices("does-not-exist-*"), f)
1423-
);
1424-
assertThat(snapshot3.state(), is(SnapshotState.SUCCESS));
1425-
}
1426-
14271387
public void testSnapshotDeleteRelocatingPrimaryIndex() throws Exception {
14281388
internalCluster().startClusterManagerOnlyNode();
14291389
final List<String> dataNodes = internalCluster().startDataOnlyNodes(2);

server/src/main/java/org/opensearch/LegacyESVersion.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@
4848
*/
4949
public class LegacyESVersion extends Version {
5050

51-
public static final LegacyESVersion V_7_4_0 = new LegacyESVersion(7040099, org.apache.lucene.util.Version.LUCENE_8_2_0);
52-
public static final LegacyESVersion V_7_4_1 = new LegacyESVersion(7040199, org.apache.lucene.util.Version.LUCENE_8_2_0);
53-
public static final LegacyESVersion V_7_4_2 = new LegacyESVersion(7040299, org.apache.lucene.util.Version.LUCENE_8_2_0);
54-
public static final LegacyESVersion V_7_5_0 = new LegacyESVersion(7050099, org.apache.lucene.util.Version.LUCENE_8_3_0);
55-
public static final LegacyESVersion V_7_5_1 = new LegacyESVersion(7050199, org.apache.lucene.util.Version.LUCENE_8_3_0);
56-
public static final LegacyESVersion V_7_5_2 = new LegacyESVersion(7050299, org.apache.lucene.util.Version.LUCENE_8_3_0);
5751
public static final LegacyESVersion V_7_6_0 = new LegacyESVersion(7060099, org.apache.lucene.util.Version.LUCENE_8_4_0);
5852
public static final LegacyESVersion V_7_6_1 = new LegacyESVersion(7060199, org.apache.lucene.util.Version.LUCENE_8_4_0);
5953
public static final LegacyESVersion V_7_6_2 = new LegacyESVersion(7060299, org.apache.lucene.util.Version.LUCENE_8_4_0);

server/src/main/java/org/opensearch/OpenSearchException.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.opensearch.index.Index;
5050
import org.opensearch.index.shard.ShardId;
5151
import org.opensearch.rest.RestStatus;
52-
import org.opensearch.search.SearchException;
5352
import org.opensearch.search.aggregations.MultiBucketConsumerService;
5453
import org.opensearch.transport.TcpTransport;
5554

@@ -317,10 +316,6 @@ public void writeTo(StreamOutput out) throws IOException {
317316
public static OpenSearchException readException(StreamInput input, int id) throws IOException {
318317
CheckedFunction<StreamInput, ? extends OpenSearchException, IOException> opensearchException = ID_TO_SUPPLIER.get(id);
319318
if (opensearchException == null) {
320-
if (id == 127 && input.getVersion().before(LegacyESVersion.V_7_5_0)) {
321-
// was SearchContextException
322-
return new SearchException(input);
323-
}
324319
throw new IllegalStateException("unknown exception for id: " + id);
325320
}
326321
return opensearchException.apply(input);
@@ -1569,13 +1564,13 @@ private enum OpenSearchExceptionHandle {
15691564
org.opensearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException.class,
15701565
org.opensearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException::new,
15711566
156,
1572-
LegacyESVersion.V_7_5_0
1567+
UNKNOWN_VERSION_ADDED
15731568
),
15741569
INGEST_PROCESSOR_EXCEPTION(
15751570
org.opensearch.ingest.IngestProcessorException.class,
15761571
org.opensearch.ingest.IngestProcessorException::new,
15771572
157,
1578-
LegacyESVersion.V_7_5_0
1573+
UNKNOWN_VERSION_ADDED
15791574
),
15801575
PEER_RECOVERY_NOT_FOUND_EXCEPTION(
15811576
org.opensearch.indices.recovery.PeerRecoveryNotFound.class,

server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,14 @@ boolean hasPassword() {
114114
@Override
115115
public void writeTo(StreamOutput out) throws IOException {
116116
super.writeTo(out);
117-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) {
118-
if (this.secureSettingsPassword == null) {
119-
out.writeOptionalBytesReference(null);
120-
} else {
121-
final byte[] passwordBytes = CharArrays.toUtf8Bytes(this.secureSettingsPassword.getChars());
122-
try {
123-
out.writeOptionalBytesReference(new BytesArray(passwordBytes));
124-
} finally {
125-
Arrays.fill(passwordBytes, (byte) 0);
126-
}
117+
if (this.secureSettingsPassword == null) {
118+
out.writeOptionalBytesReference(null);
119+
} else {
120+
final byte[] passwordBytes = CharArrays.toUtf8Bytes(this.secureSettingsPassword.getChars());
121+
try {
122+
out.writeOptionalBytesReference(new BytesArray(passwordBytes));
123+
} finally {
124+
Arrays.fill(passwordBytes, (byte) 0);
127125
}
128126
}
129127
}

server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import org.apache.logging.log4j.LogManager;
3535
import org.apache.logging.log4j.Logger;
3636
import org.apache.logging.log4j.message.ParameterizedMessage;
37-
import org.opensearch.LegacyESVersion;
38-
import org.opensearch.Version;
3937
import org.opensearch.action.ActionListener;
4038
import org.opensearch.action.ActionRunnable;
4139
import org.opensearch.action.StepListener;
@@ -91,8 +89,6 @@ public final class TransportCleanupRepositoryAction extends TransportClusterMana
9189

9290
private static final Logger logger = LogManager.getLogger(TransportCleanupRepositoryAction.class);
9391

94-
private static final Version MIN_VERSION = LegacyESVersion.V_7_4_0;
95-
9692
private final RepositoriesService repositoriesService;
9793

9894
private final SnapshotsService snapshotsService;
@@ -179,17 +175,7 @@ protected void clusterManagerOperation(
179175
ClusterState state,
180176
ActionListener<CleanupRepositoryResponse> listener
181177
) {
182-
if (state.nodes().getMinNodeVersion().onOrAfter(MIN_VERSION)) {
183-
cleanupRepo(request.name(), ActionListener.map(listener, CleanupRepositoryResponse::new));
184-
} else {
185-
throw new IllegalArgumentException(
186-
"Repository cleanup is only supported from version ["
187-
+ MIN_VERSION
188-
+ "] but the oldest node version in the cluster is ["
189-
+ state.nodes().getMinNodeVersion()
190-
+ ']'
191-
);
192-
}
178+
cleanupRepo(request.name(), ActionListener.map(listener, CleanupRepositoryResponse::new));
193179
}
194180

195181
@Override

server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/TransportCreateSnapshotAction.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,10 @@ protected void clusterManagerOperation(
103103
ClusterState state,
104104
final ActionListener<CreateSnapshotResponse> listener
105105
) {
106-
if (state.nodes().getMinNodeVersion().before(SnapshotsService.NO_REPO_INITIALIZE_VERSION)) {
107-
if (request.waitForCompletion()) {
108-
snapshotsService.executeSnapshotLegacy(request, ActionListener.map(listener, CreateSnapshotResponse::new));
109-
} else {
110-
snapshotsService.createSnapshotLegacy(request, ActionListener.map(listener, snapshot -> new CreateSnapshotResponse()));
111-
}
106+
if (request.waitForCompletion()) {
107+
snapshotsService.executeSnapshot(request, ActionListener.map(listener, CreateSnapshotResponse::new));
112108
} else {
113-
if (request.waitForCompletion()) {
114-
snapshotsService.executeSnapshot(request, ActionListener.map(listener, CreateSnapshotResponse::new));
115-
} else {
116-
snapshotsService.createSnapshot(request, ActionListener.map(listener, snapshot -> new CreateSnapshotResponse()));
117-
}
109+
snapshotsService.createSnapshot(request, ActionListener.map(listener, snapshot -> new CreateSnapshotResponse()));
118110
}
119111
}
120112
}

server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.snapshots.status;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.cluster.SnapshotsInProgress;
3736
import org.opensearch.cluster.SnapshotsInProgress.State;
3837
import org.opensearch.common.Nullable;
@@ -92,15 +91,8 @@ public class SnapshotStatus implements ToXContentObject, Writeable {
9291
state = State.fromValue(in.readByte());
9392
shards = Collections.unmodifiableList(in.readList(SnapshotIndexShardStatus::new));
9493
includeGlobalState = in.readOptionalBoolean();
95-
final long startTime;
96-
final long time;
97-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) {
98-
startTime = in.readLong();
99-
time = in.readLong();
100-
} else {
101-
startTime = 0L;
102-
time = 0L;
103-
}
94+
final long startTime = in.readLong();
95+
final long time = in.readLong();
10496
updateShardStats(startTime, time);
10597
}
10698

@@ -207,10 +199,8 @@ public void writeTo(StreamOutput out) throws IOException {
207199
out.writeByte(state.value());
208200
out.writeList(shards);
209201
out.writeOptionalBoolean(includeGlobalState);
210-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) {
211-
out.writeLong(stats.getStartTime());
212-
out.writeLong(stats.getTime());
213-
}
202+
out.writeLong(stats.getStartTime());
203+
out.writeLong(stats.getTime());
214204
}
215205

216206
@Override

server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
import com.carrotsearch.hppc.cursors.IntObjectCursor;
3636
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
37-
import org.opensearch.LegacyESVersion;
3837
import org.opensearch.OpenSearchException;
3938
import org.opensearch.action.ActionResponse;
4039
import org.opensearch.action.support.DefaultShardOperationFailedException;
@@ -247,13 +246,8 @@ public Failure(String nodeId, String index, int shardId, Throwable reason) {
247246
}
248247

249248
private Failure(StreamInput in) throws IOException {
250-
if (in.getVersion().before(LegacyESVersion.V_7_4_0)) {
251-
nodeId = in.readString();
252-
}
253249
readFrom(in, this);
254-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) {
255-
nodeId = in.readString();
256-
}
250+
nodeId = in.readString();
257251
}
258252

259253
public String nodeId() {
@@ -266,13 +260,8 @@ static Failure readFailure(StreamInput in) throws IOException {
266260

267261
@Override
268262
public void writeTo(StreamOutput out) throws IOException {
269-
if (out.getVersion().before(LegacyESVersion.V_7_4_0)) {
270-
out.writeString(nodeId);
271-
}
272263
super.writeTo(out);
273-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) {
274-
out.writeString(nodeId);
275-
}
264+
out.writeString(nodeId);
276265
}
277266

278267
@Override

server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
package org.opensearch.action.admin.indices.shrink;
3333

34-
import org.opensearch.LegacyESVersion;
3534
import org.opensearch.action.ActionRequestValidationException;
3635
import org.opensearch.action.IndicesRequest;
3736
import org.opensearch.action.admin.indices.alias.Alias;
@@ -122,9 +121,6 @@ public void writeTo(StreamOutput out) throws IOException {
122121
super.writeTo(out);
123122
targetIndexRequest.writeTo(out);
124123
out.writeString(sourceIndex);
125-
if (type == ResizeType.CLONE && out.getVersion().before(LegacyESVersion.V_7_4_0)) {
126-
throw new IllegalArgumentException("can't send clone request to a node that's older than " + LegacyESVersion.V_7_4_0);
127-
}
128124
out.writeEnum(type);
129125
out.writeOptionalBoolean(copySettings);
130126
}

server/src/main/java/org/opensearch/action/index/IndexRequest.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,8 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio
153153
version = in.readLong();
154154
versionType = VersionType.fromValue(in.readByte());
155155
pipeline = in.readOptionalString();
156-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) {
157-
finalPipeline = in.readOptionalString();
158-
}
159-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) {
160-
isPipelineResolved = in.readBoolean();
161-
}
156+
finalPipeline = in.readOptionalString();
157+
isPipelineResolved = in.readBoolean();
162158
isRetry = in.readBoolean();
163159
autoGeneratedTimestamp = in.readLong();
164160
if (in.readBoolean()) {
@@ -639,7 +635,7 @@ public void resolveRouting(Metadata metadata) {
639635
}
640636

641637
public void checkAutoIdWithOpTypeCreateSupportedByVersion(Version version) {
642-
if (id == null && opType == OpType.CREATE && version.before(LegacyESVersion.V_7_5_0)) {
638+
if (id == null && opType == OpType.CREATE && version.before(LegacyESVersion.fromId(7050099))) {
643639
throw new IllegalArgumentException(
644640
"optype create not supported for indexing requests without explicit id until all nodes " + "are on version 7.5.0 or higher"
645641
);
@@ -671,12 +667,8 @@ private void writeBody(StreamOutput out) throws IOException {
671667
out.writeLong(version);
672668
out.writeByte(versionType.getValue());
673669
out.writeOptionalString(pipeline);
674-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) {
675-
out.writeOptionalString(finalPipeline);
676-
}
677-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) {
678-
out.writeBoolean(isPipelineResolved);
679-
}
670+
out.writeOptionalString(finalPipeline);
671+
out.writeBoolean(isPipelineResolved);
680672
out.writeBoolean(isRetry);
681673
out.writeLong(autoGeneratedTimestamp);
682674
if (contentType != null) {

0 commit comments

Comments
 (0)