Skip to content

Commit

Permalink
Don't Generate an Index Setting History UUID unless it's Supported (e…
Browse files Browse the repository at this point in the history
…lastic#64164)

In 7.x we can't just by default generate this setting as it might not be
supported by data nodes that are assigned shards for an older version in mixed version
clusters.

Closes elastic#64152
  • Loading branch information
original-brownbear authored Oct 27, 2020
1 parent 261c8af commit e6505a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ setup:
---
"Create a snapshot and then restore it":

- skip:
version: "all"
reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/64152"

- do:
snapshot.create:
repository: test_repo_restore_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,17 @@ public ClusterState execute(ClusterState currentState) {
aliases.add(alias.value);
}
}
indexMdBuilder.settings(Settings.builder()
.put(snapshotIndexMetadata.getSettings())
.put(IndexMetadata.SETTING_INDEX_UUID, currentIndexMetadata.getIndexUUID())
.put(IndexMetadata.SETTING_HISTORY_UUID, UUIDs.randomBase64UUID()));
final Settings.Builder indexSettingsBuilder = Settings.builder()
.put(snapshotIndexMetadata.getSettings())
.put(IndexMetadata.SETTING_INDEX_UUID, currentIndexMetadata.getIndexUUID());
// Only add a restore uuid if either all nodes in the cluster support it (version >= 7.9) or if the
// index itself was created after 7.9 and thus won't be restored to a node that doesn't support the
// setting anyway
if (snapshotIndexMetadata.getCreationVersion().onOrAfter(Version.V_7_9_0) ||
currentState.nodes().getMinNodeVersion().onOrAfter(Version.V_7_9_0)) {
indexSettingsBuilder.put(SETTING_HISTORY_UUID, UUIDs.randomBase64UUID());
}
indexMdBuilder.settings(indexSettingsBuilder);
IndexMetadata updatedIndexMetadata = indexMdBuilder.index(renamedIndexName).build();
rtBuilder.addAsRestore(updatedIndexMetadata, recoverySource);
blocks.updateBlocks(updatedIndexMetadata);
Expand Down

0 comments on commit e6505a9

Please sign in to comment.