-
Notifications
You must be signed in to change notification settings - Fork 25.3k
License checks for archive tier #83894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1289,9 +1289,11 @@ public ClusterState execute(ClusterState currentState) { | |
final String localNodeId = clusterService.state().nodes().getLocalNodeId(); | ||
for (Map.Entry<String, IndexId> indexEntry : indicesToRestore.entrySet()) { | ||
final IndexId index = indexEntry.getValue(); | ||
final IndexMetadata originalIndexMetadata = metadata.index(index.getName()); | ||
repositoriesService.getPreRestoreChecks().forEach(check -> check.accept(originalIndexMetadata)); | ||
IndexMetadata snapshotIndexMetadata = updateIndexSettings( | ||
snapshot, | ||
metadata.index(index.getName()), | ||
originalIndexMetadata, | ||
request.indexSettings(), | ||
request.ignoreIndexSettings() | ||
); | ||
|
@@ -1591,39 +1593,40 @@ private IndexMetadata convertLegacyIndex(IndexMetadata snapshotIndexMetadata, Cl | |
if (snapshotIndexMetadata.getCreationVersion().before(Version.fromString("5.0.0"))) { | ||
throw new IllegalArgumentException("can't restore an index created before version 5.0.0"); | ||
} | ||
IndexMetadata.Builder convertedIndexMetadata = IndexMetadata.builder(snapshotIndexMetadata); | ||
MappingMetadata mappingMetadata = snapshotIndexMetadata.mapping(); | ||
Map<String, Object> loadedMappingSource = mappingMetadata.rawSourceAsMap(); | ||
|
||
// store old mapping under _meta/legacy_mappings | ||
Map<String, Object> legacyMapping = new LinkedHashMap<>(); | ||
boolean sourceOnlySnapshot = snapshotIndexMetadata.getSettings().getAsBoolean("index.source_only", false); | ||
if (sourceOnlySnapshot) { | ||
// actual mapping is under "_meta" (but strip type first) | ||
Object sourceOnlyMeta = mappingMetadata.sourceAsMap().get("_meta"); | ||
if (sourceOnlyMeta instanceof Map<?, ?> sourceOnlyMetaMap) { | ||
legacyMapping.put("legacy_mappings", sourceOnlyMetaMap); | ||
if (mappingMetadata != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the newly added test uncovered a bug as mappings can be null sometimes (even if not very useful, it's still a thing). This method was just refactored to put the existing logic under an if != null |
||
Map<String, Object> loadedMappingSource = mappingMetadata.rawSourceAsMap(); | ||
|
||
// store old mapping under _meta/legacy_mappings | ||
Map<String, Object> legacyMapping = new LinkedHashMap<>(); | ||
boolean sourceOnlySnapshot = snapshotIndexMetadata.getSettings().getAsBoolean("index.source_only", false); | ||
if (sourceOnlySnapshot) { | ||
// actual mapping is under "_meta" (but strip type first) | ||
Object sourceOnlyMeta = mappingMetadata.sourceAsMap().get("_meta"); | ||
if (sourceOnlyMeta instanceof Map<?, ?> sourceOnlyMetaMap) { | ||
legacyMapping.put("legacy_mappings", sourceOnlyMetaMap); | ||
} | ||
} else { | ||
legacyMapping.put("legacy_mappings", loadedMappingSource); | ||
} | ||
} else { | ||
legacyMapping.put("legacy_mappings", loadedMappingSource); | ||
} | ||
|
||
Map<String, Object> newMappingSource = new LinkedHashMap<>(); | ||
newMappingSource.put("_meta", legacyMapping); | ||
Map<String, Object> newMappingSource = new LinkedHashMap<>(); | ||
newMappingSource.put("_meta", legacyMapping); | ||
|
||
Map<String, Object> newMapping = new LinkedHashMap<>(); | ||
newMapping.put(mappingMetadata.type(), newMappingSource); | ||
Map<String, Object> newMapping = new LinkedHashMap<>(); | ||
newMapping.put(mappingMetadata.type(), newMappingSource); | ||
|
||
convertedIndexMetadata.putMapping(new MappingMetadata(mappingMetadata.type(), newMapping)); | ||
} | ||
|
||
convertedIndexMetadata.settings( | ||
Settings.builder() | ||
.put(snapshotIndexMetadata.getSettings()) | ||
.put(IndexMetadata.SETTING_INDEX_VERSION_COMPATIBILITY.getKey(), clusterState.getNodes().getSmallestNonClientNodeVersion()) | ||
); | ||
// TODO: _routing? Perhaps we don't need to obey any routing here as stuff is read-only anyway and get API will be disabled | ||
return IndexMetadata.builder(snapshotIndexMetadata) | ||
.putMapping(new MappingMetadata(mappingMetadata.type(), newMapping)) | ||
.settings( | ||
Settings.builder() | ||
.put(snapshotIndexMetadata.getSettings()) | ||
.put( | ||
IndexMetadata.SETTING_INDEX_VERSION_COMPATIBILITY.getKey(), | ||
clusterState.getNodes().getSmallestNonClientNodeVersion() | ||
) | ||
) | ||
.build(); | ||
return convertedIndexMetadata.build(); | ||
} | ||
|
||
private static IndexMetadata.Builder restoreToCreateNewIndex(IndexMetadata snapshotIndexMetadata, String renamedIndexName) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why you prefer returning a consumer instead of consuming IndexMetadata?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This follows the model of not calling directly into plugins, but plugins providing extensions points (at startup time) that are then being called at runtime.