Skip to content

Commit

Permalink
[Deprecate] RepositoryData.MIN_VERSION for removal in next major rele…
Browse files Browse the repository at this point in the history
…ase (#4729)

This field is only used for old snapshot generations and needs to be removed in
the next major version. This commit sets up the removal for backwards
compatibility support.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
  • Loading branch information
nknize committed Oct 11, 2022
1 parent b55719c commit 9feddc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Deprecated

### Removed
- Remove RepositoryData.MIN_VERSION support for next major release ([4729](https://github.com/opensearch-project/OpenSearch/pull/4729))

### Fixed
- PR reference to checkout code for changelog verifier ([#4296](https://github.com/opensearch-project/OpenSearch/pull/4296))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,11 @@ public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final
}
builder.endObject();
if (shouldWriteIndexGens) {
builder.field(MIN_VERSION, SnapshotsService.INDEX_GEN_IN_REPO_DATA_VERSION.toString());
if (repoMetaVersion.before(Version.V_2_4_0)) {
builder.field(MIN_VERSION, SnapshotsService.INDEX_GEN_IN_REPO_DATA_VERSION.toString());
}
builder.field(INDEX_METADATA_IDENTIFIERS, indexMetaDataGenerations.identifiers);
} else if (shouldWriteShardGens) {
} else if (shouldWriteShardGens && repoMetaVersion.before(Version.V_2_4_0)) {
// Add min version field to make it impossible for older OpenSearch versions to deserialize this object
builder.field(MIN_VERSION, SnapshotsService.SHARD_GEN_IN_REPO_DATA_VERSION.toString());
}
Expand Down Expand Up @@ -645,10 +647,14 @@ public static RepositoryData snapshotsFromXContent(XContentParser parser, long g
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
indexMetaIdentifiers = parser.mapStrings();
break;
case MIN_VERSION:
XContentParserUtils.ensureExpectedToken(XContentParser.Token.VALUE_STRING, parser.nextToken(), parser);
final Version version = Version.fromString(parser.text());
assert SnapshotsService.useShardGenerations(version);
case MIN_VERSION: // todo: remove in 3.0
if (Version.CURRENT.major < 3) {
XContentParserUtils.ensureExpectedToken(XContentParser.Token.VALUE_STRING, parser.nextToken(), parser);
final Version version = Version.fromString(parser.text());
assert SnapshotsService.useShardGenerations(version);
} else {
throw new OpenSearchParseException("Field [{}] was removed in version 2.4.0 and no longer supported.", MIN_VERSION);
}
break;
default:
XContentParserUtils.throwUnknownField(field, parser.getTokenLocation());
Expand Down

0 comments on commit 9feddc1

Please sign in to comment.