From 9a656ce54a8b9a09f4b6a626fcd294818ea1dc65 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Mon, 26 Oct 2020 15:00:32 +0100 Subject: [PATCH 1/2] Don't Generate an Index Setting History UUID unless it's Supported 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 #64152 --- .../elasticsearch/snapshots/RestoreService.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java b/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java index f6575befbdfd6..c85e4c773b41b 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java @@ -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); From 678250086f2328a44565a8937fcedf1704049c15 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Mon, 26 Oct 2020 15:06:46 +0100 Subject: [PATCH 2/2] re-enable tests --- .../rest-api-spec/test/snapshot.restore/10_basic.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/snapshot.restore/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/snapshot.restore/10_basic.yml index ad42d06fb8520..4bce99d5d97b6 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/snapshot.restore/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/snapshot.restore/10_basic.yml @@ -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