Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Reintroducing backwards compatibility logic in certain classes
Browse files Browse the repository at this point in the history
This reverts changes made in opensearch-project#4728 and opensearch-project#4702. These were only made in main and not backported to 2.x

Signed-off-by: Kartik Ganesh <gkart@amazon.com>
  • Loading branch information
kartg committed Jan 10, 2023
1 parent c47aca4 commit 4c96839
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1844,11 +1844,15 @@ public static IndexMetadata fromXContent(XContentParser parser) throws IOExcepti
// Reference:
// https://github.com/opensearch-project/OpenSearch/blob/4dde0f2a3b445b2fc61dab29c5a2178967f4a3e3/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java#L1620-L1628
Version legacyVersion = LegacyESVersion.fromId(6050099);
if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(legacyVersion)) {
Version indexCreatedVersion = Version.indexCreated(builder.settings);
if (Assertions.ENABLED && indexCreatedVersion.onOrAfter(legacyVersion)) {
assert mappingVersion : "mapping version should be present for indices";
assert settingsVersion : "settings version should be present for indices";
}
if (Assertions.ENABLED) {
// Reference:
// https://github.com/opensearch-project/OpenSearch/blob/2e4b27b243d8bd2c515f66cf86c6d1d6a601307f/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java#L1824
legacyVersion = LegacyESVersion.fromId(7020099);
if (Assertions.ENABLED && indexCreatedVersion.onOrAfter(legacyVersion)) {
assert aliasesVersion : "aliases version should be present for indices";
}
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,21 @@ public String getIndexMetaBlobId(String metaIdentifier) {
}

/**
* Get the blob id by {@link SnapshotId} and {@link IndexId}.
* Get the blob id by {@link SnapshotId} and {@link IndexId}. If none is found, we fall back to the value
* of {@link SnapshotId#getUUID()} to allow for extended backwards compatibility use-cases with
* {@link org.opensearch.LegacyESVersion} versions which used the snapshot UUID as the index metadata blob id.
*
* @param snapshotId Snapshot Id
* @param indexId Index Id
* @return blob id for the given index metadata
*/
public String indexMetaBlobId(SnapshotId snapshotId, IndexId indexId) {
final String identifier = lookup.getOrDefault(snapshotId, Collections.emptyMap()).get(indexId);
return identifiers.get(identifier);
if (identifier == null) {
return snapshotId.getUUID();
} else {
return identifiers.get(identifier);
}
}

/**
Expand Down

0 comments on commit 4c96839

Please sign in to comment.