-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Filter deprecated settings when making dest index #120163
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 120163 | ||
| summary: Filter deprecated settings when making dest index | ||
| area: Data streams | ||
| type: enhancement | ||
| issues: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,15 @@ | |
| import org.elasticsearch.client.internal.Client; | ||
| import org.elasticsearch.cluster.metadata.IndexMetadata; | ||
| import org.elasticsearch.cluster.metadata.MappingMetadata; | ||
| import org.elasticsearch.cluster.metadata.MetadataCreateIndexService; | ||
| import org.elasticsearch.cluster.service.ClusterService; | ||
| import org.elasticsearch.common.compress.CompressedXContent; | ||
| import org.elasticsearch.common.settings.IndexScopedSettings; | ||
| import org.elasticsearch.common.settings.Setting; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.common.xcontent.XContentHelper; | ||
| import org.elasticsearch.core.Nullable; | ||
| import org.elasticsearch.index.IndexNotFoundException; | ||
| import org.elasticsearch.index.IndexSettings; | ||
| import org.elasticsearch.injection.guice.Inject; | ||
| import org.elasticsearch.tasks.Task; | ||
| import org.elasticsearch.tasks.TaskId; | ||
|
|
@@ -35,6 +36,7 @@ | |
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.Set; | ||
|
|
||
| public class CreateIndexFromSourceTransportAction extends HandledTransportAction< | ||
| CreateIndexFromSourceAction.Request, | ||
|
|
@@ -122,7 +124,39 @@ private static Map<String, Object> mergeMappings(@Nullable MappingMetadata sourc | |
| // https://github.com/elastic/kibana/blob/8a8363f02cc990732eb9cbb60cd388643a336bed/x-pack | ||
| // /plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts#L155 | ||
| private Settings filterSettings(IndexMetadata sourceIndex) { | ||
| return MetadataCreateIndexService.copySettingsFromSource(false, sourceIndex.getSettings(), indexScopedSettings, Settings.builder()) | ||
|
Contributor
Author
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. As mentioned above, I decided to not use
Contributor
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. I think they are sufficiently different that I agree trying to smash them together into a single library method is messy. I think this is easier to understand. |
||
| .build(); | ||
| Settings sourceSettings = sourceIndex.getSettings(); | ||
| final Settings.Builder builder = Settings.builder(); | ||
| for (final String key : sourceSettings.keySet()) { | ||
| final Setting<?> setting = indexScopedSettings.get(key); | ||
| if (setting == null) { | ||
| assert indexScopedSettings.isPrivateSetting(key) : key; | ||
| continue; | ||
| } | ||
| if (setting.isPrivateIndex()) { | ||
| continue; | ||
| } | ||
| if (setting.getProperties().contains(Setting.Property.NotCopyableOnResize)) { | ||
| continue; | ||
| } | ||
| if (setting.getProperties().contains(Setting.Property.IndexSettingDeprecatedInV7AndRemovedInV8)) { | ||
| continue; | ||
| } | ||
| if (SPECIFIC_SETTINGS_TO_REMOVE.contains(key)) { | ||
| continue; | ||
| } | ||
| builder.copy(key, sourceSettings); | ||
| } | ||
| return builder.build(); | ||
| } | ||
|
|
||
| private static final Set<String> SPECIFIC_SETTINGS_TO_REMOVE = Set.of( | ||
| /** | ||
| * These 3 settings were removed from indices created by UA in https://github.com/elastic/kibana/pull/93293 | ||
| * That change only removed `index.translog.retention.size` and `index.translog.retention.age` if | ||
| * soft deletes were enabled. Since soft deletes are always enabled in v8, we can remove all three settings. | ||
| */ | ||
| IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), | ||
| IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), | ||
| IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey() | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
The changes to MetadataCreateIndexService just revert a change made in #116996 . Instead of making a function
copySettingsFromSourceavailable to the create-from code, I copied the relevant parts into create-from. I don't love copying the code, but the refactoring necessary to make this a function was a bit sketchy anyway.