diff --git a/modules/reindex/build.gradle b/modules/reindex/build.gradle index 8ea52de5a23a8..42e1822c20141 100644 --- a/modules/reindex/build.gradle +++ b/modules/reindex/build.gradle @@ -44,9 +44,6 @@ dependencies { clusterModules project(':modules:lang-painless') clusterModules project(':modules:parent-join') clusterModules project(":modules:rest-root") - - internalClusterTestImplementation project(':modules:lang-painless') - internalClusterTestImplementation project(':modules:lang-painless:spi') } restResources { diff --git a/modules/reindex/src/main/plugin-metadata/plugin-security.policy b/modules/reindex/src/main/plugin-metadata/plugin-security.policy index 2b6d821c4d1a8..016cc6365b6ee 100644 --- a/modules/reindex/src/main/plugin-metadata/plugin-security.policy +++ b/modules/reindex/src/main/plugin-metadata/plugin-security.policy @@ -10,9 +10,6 @@ grant { // reindex opens socket connections using the rest client permission java.net.SocketPermission "*", "connect"; - - // needed for Painless to generate runtime classes - permission java.lang.RuntimePermission "createClassLoader"; }; grant codeBase "${codebase.elasticsearch-rest-client}" { diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java index 6e936e9b1601d..faa012adcc139 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java @@ -11,9 +11,9 @@ import com.carrotsearch.randomizedtesting.annotations.Name; -import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction; import org.elasticsearch.client.Request; import org.elasticsearch.client.ResponseException; +import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.test.XContentTestUtils; import org.junit.BeforeClass; @@ -112,7 +112,7 @@ public void testGetFeatureUpgradeStatus() throws Exception { // for the next major version upgrade (see e.g. #93666). Trying to express this with features may be problematic, so we // want to keep using versions here. We also assume that for non-semantic version migrations are not required. boolean migrationNeeded = parseLegacyVersion(getOldClusterVersion()).map( - v -> v.before(TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION) + v -> v.before(SystemIndices.NO_UPGRADE_REQUIRED_VERSION) ).orElse(false); if (migrationNeeded) { assertThat(feature.get("migration_status"), equalTo("MIGRATION_NEEDED")); diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index ec8bcf8a7e043..c597681923b78 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -63,7 +63,6 @@ exports org.elasticsearch.action.admin.cluster.coordination; exports org.elasticsearch.action.admin.cluster.desirednodes; exports org.elasticsearch.action.admin.cluster.health; - exports org.elasticsearch.action.admin.cluster.migration; exports org.elasticsearch.action.admin.cluster.node.capabilities; exports org.elasticsearch.action.admin.cluster.node.hotthreads; exports org.elasticsearch.action.admin.cluster.node.info; @@ -383,7 +382,6 @@ exports org.elasticsearch.tasks; exports org.elasticsearch.threadpool; exports org.elasticsearch.transport; - exports org.elasticsearch.upgrades; exports org.elasticsearch.usage; exports org.elasticsearch.watcher; diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index ec393b7af5cdf..44d2ca5279aa0 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -26,10 +26,6 @@ import org.elasticsearch.action.admin.cluster.desirednodes.TransportUpdateDesiredNodesAction; import org.elasticsearch.action.admin.cluster.desirednodes.UpdateDesiredNodesAction; import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusAction; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeAction; -import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction; -import org.elasticsearch.action.admin.cluster.migration.TransportPostFeatureUpgradeAction; import org.elasticsearch.action.admin.cluster.node.capabilities.TransportNodesCapabilitiesAction; import org.elasticsearch.action.admin.cluster.node.features.TransportNodesFeaturesAction; import org.elasticsearch.action.admin.cluster.node.hotthreads.TransportNodesHotThreadsAction; @@ -283,7 +279,6 @@ import org.elasticsearch.rest.action.admin.cluster.RestDeleteStoredScriptAction; import org.elasticsearch.rest.action.admin.cluster.RestGetDesiredBalanceAction; import org.elasticsearch.rest.action.admin.cluster.RestGetDesiredNodesAction; -import org.elasticsearch.rest.action.admin.cluster.RestGetFeatureUpgradeStatusAction; import org.elasticsearch.rest.action.admin.cluster.RestGetRepositoriesAction; import org.elasticsearch.rest.action.admin.cluster.RestGetScriptContextAction; import org.elasticsearch.rest.action.admin.cluster.RestGetScriptLanguageAction; @@ -297,7 +292,6 @@ import org.elasticsearch.rest.action.admin.cluster.RestNodesStatsAction; import org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction; import org.elasticsearch.rest.action.admin.cluster.RestPendingClusterTasksAction; -import org.elasticsearch.rest.action.admin.cluster.RestPostFeatureUpgradeAction; import org.elasticsearch.rest.action.admin.cluster.RestPrevalidateNodeRemovalAction; import org.elasticsearch.rest.action.admin.cluster.RestPutRepositoryAction; import org.elasticsearch.rest.action.admin.cluster.RestPutStoredScriptAction; @@ -669,10 +663,7 @@ public void reg actions.register(TransportSnapshotsStatusAction.TYPE, TransportSnapshotsStatusAction.class); actions.register(SnapshottableFeaturesAction.INSTANCE, TransportSnapshottableFeaturesAction.class); actions.register(ResetFeatureStateAction.INSTANCE, TransportResetFeatureStateAction.class); - actions.register(GetFeatureUpgradeStatusAction.INSTANCE, TransportGetFeatureUpgradeStatusAction.class); - actions.register(PostFeatureUpgradeAction.INSTANCE, TransportPostFeatureUpgradeAction.class); actions.register(TransportGetShardSnapshotAction.TYPE, TransportGetShardSnapshotAction.class); - actions.register(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class); actions.register(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class); actions.register(TransportIndicesShardStoresAction.TYPE, TransportIndicesShardStoresAction.class); @@ -870,8 +861,6 @@ public void initRestHandlers(Supplier nodesInCluster, Predicate< registerHandler.accept(new RestSnapshotsStatusAction()); registerHandler.accept(new RestSnapshottableFeaturesAction()); registerHandler.accept(new RestResetFeatureStateAction()); - registerHandler.accept(new RestGetFeatureUpgradeStatusAction()); - registerHandler.accept(new RestPostFeatureUpgradeAction()); registerHandler.accept(new RestGetIndicesAction()); registerHandler.accept(new RestIndicesStatsAction()); registerHandler.accept(new RestIndicesSegmentsAction()); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java index 746ea43752b83..5411f9b91ae54 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java @@ -141,7 +141,7 @@ protected void masterOperation( listener.onFailure(new IllegalStateException(message)); return; } - updateRequest = buildSystemIndexUpdateRequest(request, cause, descriptor); + updateRequest = buildManagedSystemIndexUpdateRequest(request, cause, descriptor); } else { updateRequest = buildUpdateRequest(request, cause, indexName, resolvedAt); } @@ -173,30 +173,54 @@ private CreateIndexClusterStateUpdateRequest buildUpdateRequest( .waitForActiveShards(request.waitForActiveShards()); } - private static CreateIndexClusterStateUpdateRequest buildSystemIndexUpdateRequest( + private static CreateIndexClusterStateUpdateRequest buildManagedSystemIndexUpdateRequest( CreateIndexRequest request, String cause, SystemIndexDescriptor descriptor ) { - final Settings settings = Objects.requireNonNullElse(descriptor.getSettings(), Settings.EMPTY); + boolean indexMigrationInProgress = cause.equals(SystemIndices.MIGRATE_SYSTEM_INDEX_CAUSE) + && request.index().endsWith(SystemIndices.UPGRADED_INDEX_SUFFIX); + final Settings settings; + final String mappings; final Set aliases; - if (descriptor.getAliasName() == null) { + final String indexName; + + // if we are migrating a system index to a new index, we use settings/mappings/index name from the request, + // since it was created by SystemIndexMigrator + if (indexMigrationInProgress) { + settings = request.settings(); + mappings = request.mappings(); + indexName = request.index(); + // we will update alias later on aliases = Set.of(); } else { - aliases = Set.of(new Alias(descriptor.getAliasName()).isHidden(true).writeIndex(true)); - } + settings = Objects.requireNonNullElse(descriptor.getSettings(), Settings.EMPTY); + mappings = descriptor.getMappings(); + + if (descriptor.getAliasName() == null) { + aliases = Set.of(); + } else { + aliases = Set.of(new Alias(descriptor.getAliasName()).isHidden(true).writeIndex(true)); + } - // Throw an error if we are trying to directly create a system index other than the primary system index (or the alias) - if (request.index().equals(descriptor.getPrimaryIndex()) == false && request.index().equals(descriptor.getAliasName()) == false) { - throw new IllegalArgumentException( - "Cannot create system index with name " + request.index() + "; descriptor primary index is " + descriptor.getPrimaryIndex() - ); + // Throw an error if we are trying to directly create a system index other + // than the primary system index (or the alias, or we are migrating the index) + if (request.index().equals(descriptor.getPrimaryIndex()) == false + && request.index().equals(descriptor.getAliasName()) == false) { + throw new IllegalArgumentException( + "Cannot create system index with name " + + request.index() + + "; descriptor primary index is " + + descriptor.getPrimaryIndex() + ); + } + indexName = descriptor.getPrimaryIndex(); } - return new CreateIndexClusterStateUpdateRequest(cause, descriptor.getPrimaryIndex(), request.index()).aliases(aliases) + return new CreateIndexClusterStateUpdateRequest(cause, indexName, request.index()).aliases(aliases) .waitForActiveShards(ActiveShardCount.ALL) - .mappings(descriptor.getMappings()) + .mappings(mappings) .settings(settings); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java b/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java index efa20a41518ca..ec21160ca323d 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java @@ -85,7 +85,6 @@ import org.elasticsearch.tasks.TaskResultsService; import org.elasticsearch.telemetry.TelemetryProvider; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.upgrades.FeatureMigrationResults; import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.ParseField; @@ -244,7 +243,6 @@ public static List getNamedWriteables() { ); registerMetadataCustom(entries, DataStreamMetadata.TYPE, DataStreamMetadata::new, DataStreamMetadata::readDiffFrom); registerMetadataCustom(entries, NodesShutdownMetadata.TYPE, NodesShutdownMetadata::new, NodesShutdownMetadata::readDiffFrom); - registerMetadataCustom(entries, FeatureMigrationResults.TYPE, FeatureMigrationResults::new, FeatureMigrationResults::readDiffFrom); registerMetadataCustom(entries, DesiredNodesMetadata.TYPE, DesiredNodesMetadata::new, DesiredNodesMetadata::readDiffFrom); registerMetadataCustom( entries, diff --git a/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java b/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java index 48d492e2cc763..689b0d8e4eea7 100644 --- a/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java +++ b/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java @@ -13,7 +13,6 @@ import org.apache.lucene.util.automaton.CharacterRunAutomaton; import org.apache.lucene.util.automaton.Operations; import org.apache.lucene.util.automaton.RegExp; -import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -148,7 +147,7 @@ public class SystemIndexDescriptor implements IndexPatternMatcher, Comparable diff --git a/server/src/main/java/org/elasticsearch/indices/SystemIndices.java b/server/src/main/java/org/elasticsearch/indices/SystemIndices.java index d01763d676f37..f83a07620634e 100644 --- a/server/src/main/java/org/elasticsearch/indices/SystemIndices.java +++ b/server/src/main/java/org/elasticsearch/indices/SystemIndices.java @@ -15,8 +15,8 @@ import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.CharacterRunAutomaton; import org.apache.lucene.util.automaton.Operations; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction; import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse.ResetFeatureStateStatus; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; @@ -36,7 +36,10 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.core.Predicates; import org.elasticsearch.core.Tuple; +import org.elasticsearch.core.UpdateForV10; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; +import org.elasticsearch.index.IndexVersions; import org.elasticsearch.plugins.SystemIndexPlugin; import org.elasticsearch.snapshots.SnapshotsService; @@ -111,7 +114,16 @@ public class SystemIndices { public static final String SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY = "_system_index_access_allowed"; public static final String EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY = "_external_system_index_access_origin"; - private static final int UPGRADED_TO_VERSION = TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION.major + 1; + + /** + * These versions should be set to current major and current major's index version + */ + @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) + public static final Version NO_UPGRADE_REQUIRED_VERSION = Version.V_9_0_0; + public static final IndexVersion NO_UPGRADE_REQUIRED_INDEX_VERSION = IndexVersions.UPGRADE_TO_LUCENE_10_0_0; + + public static final String MIGRATE_SYSTEM_INDEX_CAUSE = "migrate-system-index"; + private static final int UPGRADED_TO_VERSION = NO_UPGRADE_REQUIRED_VERSION.major + 1; public static final String UPGRADED_INDEX_SUFFIX = "-reindexed-for-" + UPGRADED_TO_VERSION; private static final Automaton EMPTY = Automata.makeEmpty(); @@ -346,6 +358,7 @@ public ExecutorSelector getExecutorSelector() { /** * Finds a single matching {@link SystemIndexDescriptor}, if any, for the given index name. + * Does not take into account system data streams and their backing indices. * @param name the name of the index * @return The matching {@link SystemIndexDescriptor} or {@code null} if no descriptor is found */ @@ -354,7 +367,7 @@ public ExecutorSelector getExecutorSelector() { } @Nullable - static SystemIndexDescriptor findMatchingDescriptor(SystemIndexDescriptor[] indexDescriptors, String name) { + private static SystemIndexDescriptor findMatchingDescriptor(SystemIndexDescriptor[] indexDescriptors, String name) { SystemIndexDescriptor matchingDescriptor = null; for (SystemIndexDescriptor systemIndexDescriptor : indexDescriptors) { if (systemIndexDescriptor.matchesIndexPattern(name)) { diff --git a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java index 9ba21a7d77342..7106e3e41d4c3 100644 --- a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java +++ b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java @@ -216,7 +216,6 @@ import org.elasticsearch.threadpool.internal.BuiltInExecutorBuilders; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.upgrades.SystemIndexMigrationExecutor; import org.elasticsearch.usage.UsageService; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xcontent.NamedXContentRegistry; @@ -591,8 +590,7 @@ private void createClientAndRegistries(Settings settings, ThreadPool threadPool, IndicesModule.getNamedWriteables().stream(), searchModule.getNamedWriteables().stream(), pluginsService.flatMap(Plugin::getNamedWriteables), - ClusterModule.getNamedWriteables().stream(), - SystemIndexMigrationExecutor.getNamedWriteables().stream() + ClusterModule.getNamedWriteables().stream() ).flatMap(Function.identity()).toList() ); xContentRegistry = new NamedXContentRegistry( @@ -602,7 +600,6 @@ private void createClientAndRegistries(Settings settings, ThreadPool threadPool, searchModule.getNamedXContents().stream(), pluginsService.flatMap(Plugin::getNamedXContent), ClusterModule.getNamedXWriteables().stream(), - SystemIndexMigrationExecutor.getNamedXContentParsers().stream(), HealthNodeTaskExecutor.getNamedXContentParsers().stream() ).flatMap(Function.identity()).toList() ); @@ -1146,11 +1143,8 @@ public Map searchFields() { settingsModule, clusterService, threadPool, - systemIndices, featureService, - clusterModule.getIndexNameExpressionResolver(), - metadataUpdateSettingsService, - metadataCreateIndexService + clusterModule.getIndexNameExpressionResolver() ) ); @@ -1643,21 +1637,10 @@ private Module loadPersistentTasksService( SettingsModule settingsModule, ClusterService clusterService, ThreadPool threadPool, - SystemIndices systemIndices, FeatureService featureService, - IndexNameExpressionResolver indexNameExpressionResolver, - MetadataUpdateSettingsService metadataUpdateSettingsService, - MetadataCreateIndexService metadataCreateIndexService + IndexNameExpressionResolver indexNameExpressionResolver ) { PersistentTasksService persistentTasksService = new PersistentTasksService(clusterService, threadPool, client); - SystemIndexMigrationExecutor systemIndexMigrationExecutor = new SystemIndexMigrationExecutor( - client, - clusterService, - systemIndices, - metadataUpdateSettingsService, - metadataCreateIndexService, - settingsModule.getIndexScopedSettings() - ); HealthNodeTaskExecutor healthNodeTaskExecutor = HealthNodeTaskExecutor.create( clusterService, persistentTasksService, @@ -1665,7 +1648,7 @@ private Module loadPersistentTasksService( settingsModule.getSettings(), clusterService.getClusterSettings() ); - Stream> builtinTaskExecutors = Stream.of(systemIndexMigrationExecutor, healthNodeTaskExecutor); + Stream> builtinTaskExecutors = Stream.of(healthNodeTaskExecutor); Stream> pluginTaskExecutors = pluginsService.filterPlugins(PersistentTaskPlugin.class) .map(p -> p.getPersistentTasksExecutor(clusterService, threadPool, client, settingsModule, indexNameExpressionResolver)) diff --git a/server/src/main/java/org/elasticsearch/plugins/SystemIndexPlugin.java b/server/src/main/java/org/elasticsearch/plugins/SystemIndexPlugin.java index 5623111dbbd2c..0c970f1e88c30 100644 --- a/server/src/main/java/org/elasticsearch/plugins/SystemIndexPlugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/SystemIndexPlugin.java @@ -47,7 +47,7 @@ *

An implementation may also override {@link #prepareForIndicesMigration(ClusterService, Client, ActionListener)} and * {@link #indicesMigrationComplete(Map, ClusterService, Client, ActionListener)} in order to take special action before and after a * feature migration, which will temporarily block access to system indices. For example, a plugin might want to enter a safe mode and - * reject certain requests while the migration is in progress. See {@link org.elasticsearch.upgrades.SystemIndexMigrationExecutor} for + * reject certain requests while the migration is in progress. See org.elasticsearch.upgrades.SystemIndexMigrationExecutor for * more details. * *

After plugins are loaded, the {@link SystemIndices} class will provide the rest of the system with access to the feature's diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java index 29d23be39c77c..8abb36fff0988 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java @@ -44,6 +44,7 @@ import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_INDEX_HIDDEN; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -221,4 +222,34 @@ public void testErrorWhenCreatingNonPrimarySystemIndex() { ); } + public void testCreatingSystemIndexForMigration() { + CreateIndexRequest request = new CreateIndexRequest(); + String path = "/test"; // just to test that we pass settings + Settings settings = Settings.builder().put(SETTING_INDEX_HIDDEN, true).put(IndexMetadata.SETTING_DATA_PATH, path).build(); + request.index(MANAGED_SYSTEM_INDEX_NAME + SystemIndices.UPGRADED_INDEX_SUFFIX) + .cause(SystemIndices.MIGRATE_SYSTEM_INDEX_CAUSE) + .settings(settings); + + @SuppressWarnings("unchecked") + ActionListener mockListener = mock(ActionListener.class); + + action.masterOperation(mock(Task.class), request, CLUSTER_STATE, mockListener); + + ArgumentCaptor createRequestArgumentCaptor = ArgumentCaptor.forClass( + CreateIndexClusterStateUpdateRequest.class + ); + verify(mockListener, times(0)).onFailure(any()); + verify(metadataCreateIndexService, times(1)).createIndex( + any(TimeValue.class), + any(TimeValue.class), + any(TimeValue.class), + createRequestArgumentCaptor.capture(), + any() + ); + + CreateIndexClusterStateUpdateRequest processedRequest = createRequestArgumentCaptor.getValue(); + assertTrue(processedRequest.settings().getAsBoolean(SETTING_INDEX_HIDDEN, false)); + assertThat(processedRequest.settings().get(IndexMetadata.SETTING_DATA_PATH, ""), is(path)); + } + } diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java index 8f9c1826e97de..985453187d08c 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java @@ -49,7 +49,6 @@ import org.elasticsearch.test.AbstractChunkedSerializingTestCase; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.index.IndexVersionUtils; -import org.elasticsearch.upgrades.FeatureMigrationResults; import org.elasticsearch.xcontent.ToXContent; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentParser; @@ -2307,8 +2306,6 @@ public static int expectedChunkCount(ToXContent.Params params, Metadata metadata chunkCount += 4 + dataStreamMetadata.dataStreams().size() + dataStreamMetadata.getDataStreamAliases().size(); } else if (custom instanceof DesiredNodesMetadata) { chunkCount += 1; - } else if (custom instanceof FeatureMigrationResults featureMigrationResults) { - chunkCount += 2 + featureMigrationResults.getFeatureStatuses().size(); } else if (custom instanceof IndexGraveyard indexGraveyard) { chunkCount += 2 + indexGraveyard.getTombstones().size(); } else if (custom instanceof IngestMetadata ingestMetadata) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java index 98c12930e188e..a7580ea22182b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java @@ -6,7 +6,9 @@ */ package org.elasticsearch.xpack.core.security.authz.privilege; +import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; import org.elasticsearch.action.admin.indices.readonly.TransportAddIndexBlockAction; +import org.elasticsearch.action.admin.indices.settings.put.TransportUpdateSettingsAction; import org.elasticsearch.action.search.TransportSearchShardsAction; import org.elasticsearch.index.seqno.RetentionLeaseActions; import org.elasticsearch.index.seqno.RetentionLeaseBackgroundSyncAction; @@ -45,7 +47,9 @@ public final class SystemPrivilege extends Privilege { "indices:data/read/*", // needed for SystemIndexMigrator "indices:admin/refresh", // needed for SystemIndexMigrator "indices:admin/aliases", // needed for SystemIndexMigrator + TransportCreateIndexAction.TYPE.name() + "*", // needed for SystemIndexMigrator TransportAddIndexBlockAction.TYPE.name() + "*", // needed for SystemIndexMigrator + TransportUpdateSettingsAction.TYPE.name() + "*", // needed for SystemIndexMigrator TransportSearchShardsAction.TYPE.name(), // added so this API can be called with the system user by other APIs ActionTypes.RELOAD_REMOTE_CLUSTER_CREDENTIALS_ACTION.name() // needed for Security plugin reload of remote cluster credentials ); diff --git a/x-pack/plugin/migrate/build.gradle b/x-pack/plugin/migrate/build.gradle index 796263846859d..9908b2d01a021 100644 --- a/x-pack/plugin/migrate/build.gradle +++ b/x-pack/plugin/migrate/build.gradle @@ -21,6 +21,10 @@ dependencies { testImplementation project(':modules:data-streams') testImplementation project(path: ':modules:reindex') testImplementation project(path: ':modules:ingest-common') + testImplementation project(path: ':modules:lang-painless') + + internalClusterTestImplementation project(path: ':modules:lang-painless') + internalClusterTestImplementation project(path: ':modules:lang-painless:spi') } addQaCheckDependencies(project) diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/AbstractFeatureMigrationIntegTest.java similarity index 94% rename from modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java rename to x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/AbstractFeatureMigrationIntegTest.java index 84e45024b69ff..3749efdb88fe3 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java +++ b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/AbstractFeatureMigrationIntegTest.java @@ -1,19 +1,16 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; -import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.stats.IndexStats; @@ -31,14 +28,18 @@ import org.elasticsearch.index.IndexVersion; import org.elasticsearch.indices.AssociatedIndexDescriptor; import org.elasticsearch.indices.SystemIndexDescriptor; +import org.elasticsearch.indices.SystemIndices; +import org.elasticsearch.ingest.common.IngestCommonPlugin; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.plugins.SystemIndexPlugin; +import org.elasticsearch.reindex.ReindexPlugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.index.IndexVersionUtils; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.json.JsonXContent; +import org.elasticsearch.xpack.migrate.MigratePlugin; import org.junit.Assert; import org.junit.Before; @@ -78,9 +79,9 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase static final int INTERNAL_MANAGED_FLAG_VALUE = 1; static final String FIELD_NAME = "some_field"; protected static final IndexVersion NEEDS_UPGRADE_INDEX_VERSION = IndexVersionUtils.getPreviousMajorVersion( - TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_INDEX_VERSION + SystemIndices.NO_UPGRADE_REQUIRED_INDEX_VERSION ); - protected static final int UPGRADED_TO_VERSION = TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION.major + 1; + protected static final int UPGRADED_TO_VERSION = SystemIndices.NO_UPGRADE_REQUIRED_VERSION.major + 1; static final SystemIndexDescriptor EXTERNAL_UNMANAGED = SystemIndexDescriptor.builder() .setIndexPattern(".ext-unman-*") @@ -154,6 +155,16 @@ public T getPlugin(Class type) { return pluginsService.filterPlugins(type).findFirst().get(); } + @Override + protected Collection> nodePlugins() { + List> plugins = new ArrayList<>(super.nodePlugins()); + plugins.add(MigratePlugin.class); + plugins.add(ReindexPlugin.class); + plugins.add(TestPlugin.class); + plugins.add(IngestCommonPlugin.class); + return plugins; + } + protected void createSystemIndexForDescriptor(SystemIndexDescriptor descriptor) { assertThat( "the strategy used below to create index names for descriptors without a primary index name only works for simple patterns", diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/FeatureMigrationIT.java similarity index 95% rename from modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java rename to x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/FeatureMigrationIT.java index efca437d14eb4..cf37f39ec4d20 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java +++ b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/FeatureMigrationIT.java @@ -1,21 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.migration; +package org.elasticsearch.system_indices.action; import org.apache.lucene.util.SetOnce; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusAction; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusRequest; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeAction; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeRequest; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeResponse; import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; @@ -39,14 +31,13 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.indices.SystemIndexDescriptor; -import org.elasticsearch.migration.AbstractFeatureMigrationIntegTest.TestPlugin.BlockingActionFilter; import org.elasticsearch.painless.PainlessPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SystemIndexPlugin; -import org.elasticsearch.reindex.ReindexPlugin; +import org.elasticsearch.system_indices.action.AbstractFeatureMigrationIntegTest.TestPlugin.BlockingActionFilter; +import org.elasticsearch.system_indices.task.FeatureMigrationResults; +import org.elasticsearch.system_indices.task.SingleFeatureMigrationResult; import org.elasticsearch.test.InternalTestCluster; -import org.elasticsearch.upgrades.FeatureMigrationResults; -import org.elasticsearch.upgrades.SingleFeatureMigrationResult; import java.util.ArrayList; import java.util.Arrays; @@ -105,9 +96,7 @@ protected boolean forbidPrivateIndexSettings() { @Override protected Collection> nodePlugins() { List> plugins = new ArrayList<>(super.nodePlugins()); - plugins.add(TestPlugin.class); plugins.add(SecondTestPlugin.class); - plugins.add(ReindexPlugin.class); plugins.add(PainlessPlugin.class); return plugins; } diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/MultiFeatureMigrationIT.java similarity index 92% rename from modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java rename to x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/MultiFeatureMigrationIT.java index 01a414243f39a..d71f554e473de 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java +++ b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/MultiFeatureMigrationIT.java @@ -1,22 +1,14 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.migration; +package org.elasticsearch.system_indices.action; import org.apache.lucene.util.SetOnce; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusAction; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusRequest; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeAction; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeRequest; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeResponse; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.Metadata; @@ -27,8 +19,7 @@ import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SystemIndexPlugin; -import org.elasticsearch.reindex.ReindexPlugin; -import org.elasticsearch.upgrades.FeatureMigrationResults; +import org.elasticsearch.system_indices.task.FeatureMigrationResults; import java.util.ArrayList; import java.util.Arrays; @@ -71,9 +62,7 @@ protected boolean forbidPrivateIndexSettings() { @Override protected Collection> nodePlugins() { List> plugins = new ArrayList<>(super.nodePlugins()); - plugins.add(TestPlugin.class); plugins.add(SecondPlugin.class); - plugins.add(ReindexPlugin.class); return plugins; } diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/SystemIndexMigrationIT.java similarity index 74% rename from modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java rename to x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/SystemIndexMigrationIT.java index 018b5e5361711..c5589d705d3e4 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java +++ b/x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/system_indices/action/SystemIndexMigrationIT.java @@ -1,37 +1,25 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.migration; +package org.elasticsearch.system_indices.action; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusAction; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusRequest; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeAction; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeRequest; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.reindex.ReindexPlugin; import org.elasticsearch.test.InternalTestCluster; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.atomic.AtomicBoolean; -import static org.elasticsearch.upgrades.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; +import static org.elasticsearch.system_indices.task.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; import static org.hamcrest.Matchers.equalTo; /** @@ -51,14 +39,6 @@ protected boolean forbidPrivateIndexSettings() { return false; } - @Override - protected Collection> nodePlugins() { - List> plugins = new ArrayList<>(super.nodePlugins()); - plugins.add(TestPlugin.class); - plugins.add(ReindexPlugin.class); - return plugins; - } - public void testSystemIndexMigrationCanBeInterruptedWithShutdown() throws Exception { CyclicBarrier taskCreated = new CyclicBarrier(2); CyclicBarrier shutdownCompleted = new CyclicBarrier(2); diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusAction.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusAction.java similarity index 55% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusAction.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusAction.java index 23b094fc72b6f..31511d6a752cc 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusAction.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusAction.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.action.ActionType; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusRequest.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusRequest.java similarity index 65% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusRequest.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusRequest.java index 959197f1e12b6..18287dd280630 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusRequest.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusRequest.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.MasterNodeRequest; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponse.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusResponse.java similarity index 96% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponse.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusResponse.java index f65152a8b72e9..b36eb1bd00f33 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponse.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusResponse.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionResponse; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeAction.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeAction.java similarity index 54% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeAction.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeAction.java index d5f881cef9e5c..525c0b78f9be3 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeAction.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeAction.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.action.ActionType; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeRequest.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeRequest.java similarity index 64% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeRequest.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeRequest.java index 5681043148821..9b8a4000a0e44 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeRequest.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeRequest.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.MasterNodeRequest; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponse.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeResponse.java similarity index 93% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponse.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeResponse.java index 56c0d2eaad900..c6d8adf8a61c0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponse.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeResponse.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionResponse; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusAction.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/TransportGetFeatureUpgradeStatusAction.java similarity index 79% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusAction.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/TransportGetFeatureUpgradeStatusAction.java index 0e6586b7998f1..4a524ae90db84 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusAction.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/TransportGetFeatureUpgradeStatusAction.java @@ -1,15 +1,12 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; @@ -18,31 +15,30 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.util.concurrent.EsExecutors; -import org.elasticsearch.core.UpdateForV10; import org.elasticsearch.index.IndexVersion; -import org.elasticsearch.index.IndexVersions; import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.injection.guice.Inject; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; +import org.elasticsearch.system_indices.task.FeatureMigrationResults; +import org.elasticsearch.system_indices.task.SingleFeatureMigrationResult; +import org.elasticsearch.system_indices.task.SystemIndexMigrationTaskParams; +import org.elasticsearch.system_indices.task.SystemIndexMigrationTaskState; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.upgrades.FeatureMigrationResults; -import org.elasticsearch.upgrades.SingleFeatureMigrationResult; -import org.elasticsearch.upgrades.SystemIndexMigrationTaskParams; -import org.elasticsearch.upgrades.SystemIndexMigrationTaskState; import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.stream.Stream; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.ERROR; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.IN_PROGRESS; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.MIGRATION_NEEDED; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED; +import static org.elasticsearch.indices.SystemIndices.NO_UPGRADE_REQUIRED_INDEX_VERSION; import static org.elasticsearch.indices.SystemIndices.UPGRADED_INDEX_SUFFIX; -import static org.elasticsearch.upgrades.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.ERROR; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.IN_PROGRESS; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.MIGRATION_NEEDED; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED; +import static org.elasticsearch.system_indices.task.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; /** * Transport class for the get feature upgrade status action @@ -51,13 +47,6 @@ public class TransportGetFeatureUpgradeStatusAction extends TransportMasterNodeA GetFeatureUpgradeStatusRequest, GetFeatureUpgradeStatusResponse> { - /** - * These versions should be set to current major and current major's index version - */ - @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) - public static final Version NO_UPGRADE_REQUIRED_VERSION = Version.V_9_0_0; - public static final IndexVersion NO_UPGRADE_REQUIRED_INDEX_VERSION = IndexVersions.UPGRADE_TO_LUCENE_10_0_0; - private final SystemIndices systemIndices; @Inject diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportPostFeatureUpgradeAction.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/TransportPostFeatureUpgradeAction.java similarity index 85% rename from server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportPostFeatureUpgradeAction.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/TransportPostFeatureUpgradeAction.java index 08438de4bfea1..ee4ee93568aa6 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportPostFeatureUpgradeAction.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/action/TransportPostFeatureUpgradeAction.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -24,18 +22,18 @@ import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.injection.guice.Inject; import org.elasticsearch.persistent.PersistentTasksService; +import org.elasticsearch.system_indices.task.SystemIndexMigrationTaskParams; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.upgrades.SystemIndexMigrationTaskParams; import java.util.Comparator; import java.util.EnumSet; import java.util.List; import java.util.Set; -import static org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction.getFeatureUpgradeStatus; -import static org.elasticsearch.upgrades.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; +import static org.elasticsearch.system_indices.action.TransportGetFeatureUpgradeStatusAction.getFeatureUpgradeStatus; +import static org.elasticsearch.system_indices.task.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; /** * Transport action for post feature upgrade action diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetFeatureUpgradeStatusAction.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/rest/RestGetFeatureUpgradeStatusAction.java similarity index 67% rename from server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetFeatureUpgradeStatusAction.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/rest/RestGetFeatureUpgradeStatusAction.java index 0a2fc9cc5c92a..47d6ff3b1e10c 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetFeatureUpgradeStatusAction.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/rest/RestGetFeatureUpgradeStatusAction.java @@ -1,20 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.rest.action.admin.cluster; +package org.elasticsearch.system_indices.rest; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusAction; -import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusRequest; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; +import org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusAction; +import org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusRequest; import java.io.IOException; import java.util.List; diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPostFeatureUpgradeAction.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/rest/RestPostFeatureUpgradeAction.java similarity index 67% rename from server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPostFeatureUpgradeAction.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/rest/RestPostFeatureUpgradeAction.java index 38e81668dd0eb..97d6e11cc9fa3 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPostFeatureUpgradeAction.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/rest/RestPostFeatureUpgradeAction.java @@ -1,20 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.rest.action.admin.cluster; +package org.elasticsearch.system_indices.rest; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeAction; -import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeRequest; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; +import org.elasticsearch.system_indices.action.PostFeatureUpgradeAction; +import org.elasticsearch.system_indices.action.PostFeatureUpgradeRequest; import java.io.IOException; import java.util.List; diff --git a/server/src/main/java/org/elasticsearch/upgrades/FeatureMigrationResults.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/FeatureMigrationResults.java similarity index 93% rename from server/src/main/java/org/elasticsearch/upgrades/FeatureMigrationResults.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/FeatureMigrationResults.java index 38d6f338073de..b3c9adc1bbf2a 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/FeatureMigrationResults.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/FeatureMigrationResults.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.TransportVersion; import org.elasticsearch.TransportVersions; diff --git a/server/src/main/java/org/elasticsearch/upgrades/MigrationResultsUpdateTask.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/MigrationResultsUpdateTask.java similarity index 90% rename from server/src/main/java/org/elasticsearch/upgrades/MigrationResultsUpdateTask.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/MigrationResultsUpdateTask.java index 45666ba1ca528..3e0f500cb9c4b 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/MigrationResultsUpdateTask.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/MigrationResultsUpdateTask.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/server/src/main/java/org/elasticsearch/upgrades/SingleFeatureMigrationResult.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SingleFeatureMigrationResult.java similarity index 92% rename from server/src/main/java/org/elasticsearch/upgrades/SingleFeatureMigrationResult.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SingleFeatureMigrationResult.java index 5dac57fdf8d41..266ebff4239fc 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/SingleFeatureMigrationResult.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SingleFeatureMigrationResult.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.cluster.SimpleDiffable; diff --git a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationExecutor.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationExecutor.java similarity index 76% rename from server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationExecutor.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationExecutor.java index 99e739919effc..b37a7a15a8310 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationExecutor.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationExecutor.java @@ -1,18 +1,14 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.metadata.MetadataCreateIndexService; -import org.elasticsearch.cluster.metadata.MetadataUpdateSettingsService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -31,7 +27,7 @@ import java.util.List; import java.util.Map; -import static org.elasticsearch.upgrades.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; +import static org.elasticsearch.system_indices.task.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; /** * Starts the process of migrating system indices. See {@link SystemIndexMigrator} for the actual migration logic. @@ -40,24 +36,18 @@ public class SystemIndexMigrationExecutor extends PersistentTasksExecutor taskInProgress, Map headers ) { - return new SystemIndexMigrator( - client, - id, - type, - action, - parentTaskId, - taskInProgress.getParams(), - headers, - clusterService, - systemIndices, - metadataUpdateSettingsService, - metadataCreateIndexService, - indexScopedSettings - ); + return new SystemIndexMigrator(client, id, type, action, parentTaskId, headers, clusterService, systemIndices, indexScopedSettings); } @Override diff --git a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationInfo.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationInfo.java similarity index 96% rename from server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationInfo.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationInfo.java index 4768a5cae7dad..86e9a141a89b9 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationInfo.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationInfo.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParams.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParams.java similarity index 81% rename from server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParams.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParams.java index acdacac748a63..b6be87b25d762 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParams.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParams.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.StreamInput; @@ -19,7 +17,7 @@ import java.io.IOException; -import static org.elasticsearch.upgrades.FeatureMigrationResults.MIGRATION_ADDED_VERSION; +import static org.elasticsearch.system_indices.task.FeatureMigrationResults.MIGRATION_ADDED_VERSION; /** * The params used to initialize {@link SystemIndexMigrator} when it's initially kicked off. diff --git a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskState.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskState.java similarity index 91% rename from server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskState.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskState.java index 7bd9a43eca36c..cb7ac812bb8b1 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskState.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskState.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.internal.Client; @@ -25,7 +23,7 @@ import java.util.Map; import java.util.Objects; -import static org.elasticsearch.upgrades.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; +import static org.elasticsearch.system_indices.task.SystemIndexMigrationTaskParams.SYSTEM_INDEX_UPGRADE_TASK_NAME; import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg; /** diff --git a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrator.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrator.java similarity index 92% rename from server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrator.java rename to x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrator.java index 9947606470178..6188109381f52 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrator.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/system_indices/task/SystemIndexMigrator.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -16,13 +14,14 @@ import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; -import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; +import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; +import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.readonly.AddIndexBlockRequest; -import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsClusterStateUpdateRequest; +import org.elasticsearch.action.admin.indices.settings.put.TransportUpdateSettingsAction; +import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.MasterNodeRequest; -import org.elasticsearch.action.support.master.ShardsAcknowledgedResponse; import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.ParentTaskAssigningClient; import org.elasticsearch.cluster.ClusterState; @@ -30,9 +29,7 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexTemplateMetadata; import org.elasticsearch.cluster.metadata.Metadata; -import org.elasticsearch.cluster.metadata.MetadataCreateIndexService; import org.elasticsearch.cluster.metadata.MetadataIndexTemplateService; -import org.elasticsearch.cluster.metadata.MetadataUpdateSettingsService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.IndexScopedSettings; @@ -59,10 +56,10 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import static org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_INDEX_VERSION; import static org.elasticsearch.cluster.metadata.IndexMetadata.APIBlock.WRITE; import static org.elasticsearch.cluster.metadata.IndexMetadata.State.CLOSE; import static org.elasticsearch.core.Strings.format; +import static org.elasticsearch.indices.SystemIndices.NO_UPGRADE_REQUIRED_INDEX_VERSION; /** * This is where the logic to actually perform the migration lives - {@link SystemIndexMigrator#run(SystemIndexMigrationTaskState)} will @@ -77,8 +74,6 @@ public class SystemIndexMigrator extends AllocatedPersistentTask { private final ParentTaskAssigningClient baseClient; private final ClusterService clusterService; private final SystemIndices systemIndices; - private final MetadataUpdateSettingsService metadataUpdateSettingsService; - private final MetadataCreateIndexService metadataCreateIndexService; private final IndexScopedSettings indexScopedSettings; // In-memory state @@ -94,20 +89,15 @@ public SystemIndexMigrator( String type, String action, TaskId parentTask, - SystemIndexMigrationTaskParams params, Map headers, ClusterService clusterService, SystemIndices systemIndices, - MetadataUpdateSettingsService metadataUpdateSettingsService, - MetadataCreateIndexService metadataCreateIndexService, IndexScopedSettings indexScopedSettings ) { super(id, type, action, "system-index-migrator", parentTask, headers); this.baseClient = new ParentTaskAssigningClient(client, parentTask); this.clusterService = clusterService; this.systemIndices = systemIndices; - this.metadataUpdateSettingsService = metadataUpdateSettingsService; - this.metadataCreateIndexService = metadataCreateIndexService; this.indexScopedSettings = indexScopedSettings; } @@ -468,15 +458,10 @@ private void migrateSingleIndex(ClusterState clusterState, Consumer listener) { + private void createIndex(SystemIndexMigrationInfo migrationInfo, ActionListener listener) { logger.info("creating new system index [{}] from feature [{}]", migrationInfo.getNextIndexName(), migrationInfo.getFeatureName()); - final CreateIndexClusterStateUpdateRequest createRequest = new CreateIndexClusterStateUpdateRequest( - "migrate-system-index", - migrationInfo.getNextIndexName(), - migrationInfo.getNextIndexName() - ); - + CreateIndexRequest createIndexRequest = new CreateIndexRequest(migrationInfo.getNextIndexName()); Settings.Builder settingsBuilder = Settings.builder(); if (Objects.nonNull(migrationInfo.getSettings())) { settingsBuilder.put(migrationInfo.getSettings()); @@ -484,28 +469,32 @@ private void createIndex(SystemIndexMigrationInfo migrationInfo, ActionListener< settingsBuilder.remove("index.blocks.read"); settingsBuilder.remove("index.blocks.metadata"); } - createRequest.waitForActiveShards(ActiveShardCount.ALL) - .mappings(migrationInfo.getMappings()) + createIndexRequest.cause(SystemIndices.MIGRATE_SYSTEM_INDEX_CAUSE) + .ackTimeout(TimeValue.ZERO) + .masterNodeTimeout(MasterNodeRequest.INFINITE_MASTER_NODE_TIMEOUT) + .waitForActiveShards(ActiveShardCount.ALL) + .mapping(migrationInfo.getMappings()) .settings(Objects.requireNonNullElse(settingsBuilder.build(), Settings.EMPTY)); - metadataCreateIndexService.createIndex( - MasterNodeRequest.INFINITE_MASTER_NODE_TIMEOUT, - TimeValue.ZERO, - null, - createRequest, - listener - ); + + baseClient.admin().indices().create(createIndexRequest, listener); } - private void createIndexRetryOnFailure(SystemIndexMigrationInfo migrationInfo, ActionListener listener) { + private void createIndexRetryOnFailure(SystemIndexMigrationInfo migrationInfo, ActionListener listener) { createIndex(migrationInfo, listener.delegateResponse((l, e) -> { - logger.warn("createIndex failed, retrying after removing index [{}] from previous attempt", migrationInfo.getNextIndexName()); + logger.warn( + "createIndex failed with \"{}\", retrying after removing index [{}] from previous attempt", + e.getMessage(), + migrationInfo.getNextIndexName() + ); deleteIndex(migrationInfo, ActionListener.wrap(cleanupResponse -> createIndex(migrationInfo, l.delegateResponse((l3, e3) -> { + e3.addSuppressed(e); logger.error( "createIndex failed after retrying, aborting system index migration. index: " + migrationInfo.getNextIndexName(), e3 ); l.onFailure(e3); })), e2 -> { + e2.addSuppressed(e); logger.error("deleteIndex failed, aborting system index migration. index: " + migrationInfo.getNextIndexName(), e2); l.onFailure(e2); })); @@ -568,17 +557,10 @@ private void setWriteBlock(Index index, boolean readOnlyValue, ActionListener systemIndices = new SetOnce<>(); + @Override public Collection createComponents(PluginServices services) { + systemIndices.set(services.systemIndices()); + var registry = new MigrateTemplateRegistry( services.environment().settings(), services.clusterService(), @@ -97,6 +114,9 @@ public List getRestHandlers( handlers.add(new RestGetMigrationReindexStatusAction()); handlers.add(new RestCancelReindexDataStreamAction()); handlers.add(new RestCreateIndexFromSourceAction()); + + handlers.add(new RestGetFeatureUpgradeStatusAction()); + handlers.add(new RestPostFeatureUpgradeAction()); return handlers; } @@ -109,40 +129,51 @@ public List getRestHandlers( actions.add(new ActionHandler<>(ReindexDataStreamIndexAction.INSTANCE, ReindexDataStreamIndexTransportAction.class)); actions.add(new ActionHandler<>(CreateIndexFromSourceAction.INSTANCE, CreateIndexFromSourceTransportAction.class)); actions.add(new ActionHandler<>(CopyLifecycleIndexMetadataAction.INSTANCE, CopyLifecycleIndexMetadataTransportAction.class)); + + actions.add(new ActionHandler<>(GetFeatureUpgradeStatusAction.INSTANCE, TransportGetFeatureUpgradeStatusAction.class)); + actions.add(new ActionHandler<>(PostFeatureUpgradeAction.INSTANCE, TransportPostFeatureUpgradeAction.class)); return actions; } @Override public List getNamedXContent() { - return List.of( - new NamedXContentRegistry.Entry( - PersistentTaskState.class, - new ParseField(ReindexDataStreamPersistentTaskState.NAME), - ReindexDataStreamPersistentTaskState::fromXContent - ), - new NamedXContentRegistry.Entry( - PersistentTaskParams.class, - new ParseField(ReindexDataStreamTaskParams.NAME), - ReindexDataStreamTaskParams::fromXContent + return Stream.concat( + SystemIndexMigrationExecutor.getNamedXContentParsers().stream(), + Stream.of( + new NamedXContentRegistry.Entry( + PersistentTaskState.class, + new ParseField(ReindexDataStreamPersistentTaskState.NAME), + ReindexDataStreamPersistentTaskState::fromXContent + ), + new NamedXContentRegistry.Entry( + PersistentTaskParams.class, + new ParseField(ReindexDataStreamTaskParams.NAME), + ReindexDataStreamTaskParams::fromXContent + ) ) - ); + ).toList(); } @Override public List getNamedWriteables() { - return List.of( - new NamedWriteableRegistry.Entry( - PersistentTaskState.class, - ReindexDataStreamPersistentTaskState.NAME, - ReindexDataStreamPersistentTaskState::new - ), - new NamedWriteableRegistry.Entry( - PersistentTaskParams.class, - ReindexDataStreamTaskParams.NAME, - ReindexDataStreamTaskParams::new - ), - new NamedWriteableRegistry.Entry(Task.Status.class, ReindexDataStreamStatus.NAME, ReindexDataStreamStatus::new) - ); + return Stream.concat( + SystemIndexMigrationExecutor.getNamedWriteables().stream(), + Stream.of( + new NamedWriteableRegistry.Entry(Metadata.Custom.class, FeatureMigrationResults.TYPE, FeatureMigrationResults::new), + new NamedWriteableRegistry.Entry(NamedDiff.class, FeatureMigrationResults.TYPE, FeatureMigrationResults::readDiffFrom), + new NamedWriteableRegistry.Entry( + PersistentTaskState.class, + ReindexDataStreamPersistentTaskState.NAME, + ReindexDataStreamPersistentTaskState::new + ), + new NamedWriteableRegistry.Entry( + PersistentTaskParams.class, + ReindexDataStreamTaskParams.NAME, + ReindexDataStreamTaskParams::new + ), + new NamedWriteableRegistry.Entry(Task.Status.class, ReindexDataStreamStatus.NAME, ReindexDataStreamStatus::new) + ) + ).toList(); } @Override @@ -154,6 +185,7 @@ public List> getPersistentTasksExecutor( IndexNameExpressionResolver expressionResolver ) { return List.of( + new SystemIndexMigrationExecutor(client, clusterService, systemIndices.get(), settingsModule.getIndexScopedSettings()), new ReindexDataStreamPersistentTaskExecutor( new OriginSettingClient(client, REINDEX_DATA_STREAM_ORIGIN), clusterService, diff --git a/x-pack/plugin/migrate/src/main/plugin-metadata/plugin-security.policy b/x-pack/plugin/migrate/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 0000000000000..db02e9267218a --- /dev/null +++ b/x-pack/plugin/migrate/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +grant { + // needed for Painless to generate runtime classes + permission java.lang.RuntimePermission "createClassLoader"; +}; diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponseTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusResponseTests.java similarity index 76% rename from server/src/test/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponseTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusResponseTests.java index ea538e5b085cc..781cf277a26dd 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponseTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/GetFeatureUpgradeStatusResponseTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.index.IndexVersion; @@ -16,10 +14,10 @@ import java.util.Collections; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.ERROR; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.IN_PROGRESS; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.MIGRATION_NEEDED; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.ERROR; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.IN_PROGRESS; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.MIGRATION_NEEDED; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; @@ -37,7 +35,7 @@ protected Writeable.Reader instanceReader() { protected GetFeatureUpgradeStatusResponse createTestInstance() { return new GetFeatureUpgradeStatusResponse( randomList(8, GetFeatureUpgradeStatusResponseTests::createFeatureStatus), - randomFrom(org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.values()) + randomFrom(GetFeatureUpgradeStatusResponse.UpgradeStatus.values()) ); } @@ -51,10 +49,7 @@ protected GetFeatureUpgradeStatusResponse mutateInstance(GetFeatureUpgradeStatus GetFeatureUpgradeStatusResponseTests::createFeatureStatus ) ), - randomValueOtherThan( - instance.getUpgradeStatus(), - () -> randomFrom(org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.values()) - ) + randomValueOtherThan(instance.getUpgradeStatus(), () -> randomFrom(GetFeatureUpgradeStatusResponse.UpgradeStatus.values())) ); } @@ -92,7 +87,7 @@ private static GetFeatureUpgradeStatusResponse.FeatureUpgradeStatus createFeatur return new GetFeatureUpgradeStatusResponse.FeatureUpgradeStatus( randomAlphaOfLengthBetween(3, 20), randomFrom(IndexVersion.current(), IndexVersions.MINIMUM_COMPATIBLE), - randomFrom(org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.values()), + randomFrom(GetFeatureUpgradeStatusResponse.UpgradeStatus.values()), randomList(4, GetFeatureUpgradeStatusResponseTests::getIndexInfo) ); } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponseTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeResponseTests.java similarity index 85% rename from server/src/test/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponseTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeResponseTests.java index 13b6a268ab21f..33ee910b70179 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponseTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/PostFeatureUpgradeResponseTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.io.stream.Writeable; diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/TransportGetFeatureUpgradeStatusActionTests.java similarity index 87% rename from server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/TransportGetFeatureUpgradeStatusActionTests.java index 9fef4c4ed328f..28aa0bdfae46a 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/action/TransportGetFeatureUpgradeStatusActionTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.action.admin.cluster.migration; +package org.elasticsearch.system_indices.action; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -24,7 +22,7 @@ import java.util.List; import java.util.Map; -import static org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusResponse.UpgradeStatus.MIGRATION_NEEDED; +import static org.elasticsearch.system_indices.action.GetFeatureUpgradeStatusResponse.UpgradeStatus.MIGRATION_NEEDED; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; diff --git a/server/src/test/java/org/elasticsearch/upgrades/FeatureMigrationResultsTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/FeatureMigrationResultsTests.java similarity index 91% rename from server/src/test/java/org/elasticsearch/upgrades/FeatureMigrationResultsTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/FeatureMigrationResultsTests.java index 8eee57b6d9419..3cbbfb062ea87 100644 --- a/server/src/test/java/org/elasticsearch/upgrades/FeatureMigrationResultsTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/FeatureMigrationResultsTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.cluster.Diff; diff --git a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParamsTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParamsTests.java similarity index 78% rename from server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParamsTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParamsTests.java index c9f2102dd446c..bc111b44aaa9f 100644 --- a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParamsTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParamsTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; diff --git a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParamsXContentTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParamsXContentTests.java similarity index 70% rename from server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParamsXContentTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParamsXContentTests.java index b66ba693d9aad..bedda2b7b617a 100644 --- a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskParamsXContentTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskParamsXContentTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.test.AbstractXContentTestCase; import org.elasticsearch.xcontent.NamedXContentRegistry; diff --git a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskStateTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskStateTests.java similarity index 89% rename from server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskStateTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskStateTests.java index 427d4d805fea0..dff6cfcdd19ac 100644 --- a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskStateTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskStateTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; diff --git a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskStateXContentTests.java b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskStateXContentTests.java similarity index 76% rename from server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskStateXContentTests.java rename to x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskStateXContentTests.java index a5be76f9a18a3..40f635ac4b09d 100644 --- a/server/src/test/java/org/elasticsearch/upgrades/SystemIndexMigrationTaskStateXContentTests.java +++ b/x-pack/plugin/migrate/src/test/java/org/elasticsearch/system_indices/task/SystemIndexMigrationTaskStateXContentTests.java @@ -1,13 +1,11 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ -package org.elasticsearch.upgrades; +package org.elasticsearch.system_indices.task; import org.elasticsearch.test.AbstractXContentTestCase; import org.elasticsearch.xcontent.NamedXContentRegistry; diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java index d8b0d5138a93d..186e20a6a166f 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java @@ -339,7 +339,7 @@ public void testCleanUpMigratedSystemIndexAfterIndicesAreDeleted() throws Except /** * Mimics migration of the {@link SearchableSnapshots#SNAPSHOT_BLOB_CACHE_INDEX} as done in - * {@link org.elasticsearch.upgrades.SystemIndexMigrator}, where the index is re-indexed, and replaced by an alias. + * org.elasticsearch.upgrades.SystemIndexMigrator, where the index is re-indexed, and replaced by an alias. */ private void migrateTheSystemIndex() { final var migratedSnapshotBlobCache = SNAPSHOT_BLOB_CACHE_INDEX + SystemIndices.UPGRADED_INDEX_SUFFIX; diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/migration/10_get_feature_upgrade_status.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migration/10_get_feature_upgrade_status.yml similarity index 100% rename from rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/migration/10_get_feature_upgrade_status.yml rename to x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migration/10_get_feature_upgrade_status.yml diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/migration/20_post_feature_upgrade.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migration/20_post_feature_upgrade.yml similarity index 56% rename from rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/migration/20_post_feature_upgrade.yml rename to x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migration/20_post_feature_upgrade.yml index b1d6b0630d0a7..0f29389953c38 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/migration/20_post_feature_upgrade.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migration/20_post_feature_upgrade.yml @@ -1,11 +1,10 @@ -"Get feature upgrade status": +"Start feature upgrade": - requires: cluster_features: ["gte_v7.16.0"] reason: "Endpoint added in 7.16.0" - do: - migration.get_feature_upgrade_status: {} + migration.post_feature_upgrade: {} - is_false: accepted - - is_true: features