From b6244075f96dce456b595553435f29962f7f0446 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Tue, 10 Jun 2025 08:43:16 +0200 Subject: [PATCH] Make use of new `projectClient` method and remove old one We added a new `projectClient` method on `Client` in #129174. We now update the usages of the old method (on `ProjectResolver`) to use the new one and we delete the old method. --- .../datastreams/DataStreamsPlugin.java | 3 +- .../lifecycle/DataStreamLifecycleService.java | 18 +++++------- .../DataStreamLifecycleServiceTests.java | 8 ++--- .../cluster/project/ProjectResolver.java | 29 ------------------- .../elasticsearch/test/client/NoOpClient.java | 5 ++++ .../apmdata/APMIndexTemplateRegistry.java | 7 ++--- .../xpack/apmdata/APMPlugin.java | 9 +----- .../xpack/apmdata/APMDSLOnlyTests.java | 4 +-- .../APMIndexTemplateRegistryTests.java | 8 ++--- .../xpack/apmdata/VerifyingClient.java | 3 +- .../IndexTemplateRegistryRolloverIT.java | 4 +-- .../RolloverEnabledTestTemplateRegistry.java | 6 ++-- .../core/template/IndexTemplateRegistry.java | 20 +++++-------- .../core/template/YamlTemplateRegistry.java | 11 +++---- .../template/IndexTemplateRegistryTests.java | 11 ++----- .../TestRegistryWithCustomPlugin.java | 6 ++-- .../xpack/deprecation/Deprecation.java | 3 +- .../DeprecationIndexingTemplateRegistry.java | 6 ++-- .../xpack/application/EnterpriseSearch.java | 6 ++-- .../analytics/AnalyticsTemplateRegistry.java | 6 ++-- .../connector/ConnectorTemplateRegistry.java | 6 ++-- .../AnalyticsTemplateRegistryTests.java | 10 ++----- .../ConnectorTemplateRegistryTests.java | 10 ++----- .../org/elasticsearch/xpack/fleet/Fleet.java | 3 +- .../xpack/fleet/FleetTemplateRegistry.java | 6 ++-- .../sp/SamlServiceProviderIndexTests.java | 3 +- .../xpack/idp/IdentityProviderPlugin.java | 3 +- ...lServiceProviderIndexTemplateRegistry.java | 6 ++-- .../xpack/ilm/IndexLifecycle.java | 3 +- .../history/ILMHistoryTemplateRegistry.java | 6 ++-- .../ilm/history/ILMHistoryStoreTests.java | 4 +-- .../xpack/migrate/MigratePlugin.java | 3 +- .../migrate/MigrateTemplateRegistry.java | 6 ++-- .../xpack/ml/MachineLearning.java | 3 +- .../xpack/ml/MlIndexTemplateRegistry.java | 6 ++-- .../ml/MlIndexTemplateRegistryTests.java | 8 ++--- .../xpack/monitoring/Monitoring.java | 3 +- .../MonitoringTemplateRegistry.java | 6 ++-- .../MonitoringTemplateRegistryTests.java | 17 +++-------- .../oteldata/OTelIndexTemplateRegistry.java | 6 ++-- .../xpack/oteldata/OTelPlugin.java | 9 +----- .../xpack/profiling/ProfilingPlugin.java | 11 +------ .../ProfilingIndexTemplateRegistry.java | 6 ++-- .../ProfilingIndexTemplateRegistryTests.java | 10 +------ .../persistence/VerifyingClient.java | 3 +- .../xpack/slm/SnapshotLifecycle.java | 3 +- .../SnapshotLifecycleTemplateRegistry.java | 6 ++-- ...napshotLifecycleTemplateRegistryTests.java | 14 ++------- .../stack/LegacyStackTemplateRegistry.java | 6 ++-- .../xpack/stack/StackPlugin.java | 6 ++-- .../xpack/stack/StackTemplateRegistry.java | 6 ++-- .../LegacyStackTemplateRegistryTests.java | 10 +------ ...StackRegistryWithNonRequiredTemplates.java | 6 ++-- .../stack/StackTemplateRegistryTests.java | 20 ++++--------- .../elasticsearch/xpack/watcher/Watcher.java | 3 +- .../support/WatcherIndexTemplateRegistry.java | 6 ++-- .../WatcherIndexTemplateRegistryTests.java | 13 +++------ 57 files changed, 118 insertions(+), 311 deletions(-) diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamsPlugin.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamsPlugin.java index b3802f1bbbb1c..eb33e2a3f158b 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamsPlugin.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamsPlugin.java @@ -214,8 +214,7 @@ public Collection createComponents(PluginServices services) { errorStoreInitialisationService.get(), services.allocationService(), dataStreamLifecycleErrorsPublisher.get(), - services.dataStreamGlobalRetentionSettings(), - services.projectResolver() + services.dataStreamGlobalRetentionSettings() ) ); dataLifecycleInitialisationService.get().init(); diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java index 65618e0ae1032..776ee03928b27 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java @@ -54,7 +54,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.SelectorResolver; import org.elasticsearch.cluster.metadata.ProjectId; import org.elasticsearch.cluster.metadata.ProjectMetadata; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.MasterServiceTaskQueue; @@ -169,7 +168,6 @@ public class DataStreamLifecycleService implements ClusterStateListener, Closeab final ResultDeduplicator, Void> clusterStateChangesDeduplicator; private final DataStreamLifecycleHealthInfoPublisher dslHealthInfoPublisher; private final DataStreamGlobalRetentionSettings globalRetentionSettings; - private final ProjectResolver projectResolver; private LongSupplier nowSupplier; private final Clock clock; private final DataStreamLifecycleErrorStore errorStore; @@ -218,8 +216,7 @@ public DataStreamLifecycleService( DataStreamLifecycleErrorStore errorStore, AllocationService allocationService, DataStreamLifecycleHealthInfoPublisher dataStreamLifecycleHealthInfoPublisher, - DataStreamGlobalRetentionSettings globalRetentionSettings, - ProjectResolver projectResolver + DataStreamGlobalRetentionSettings globalRetentionSettings ) { this.settings = settings; this.client = client; @@ -231,7 +228,6 @@ public DataStreamLifecycleService( this.nowSupplier = nowSupplier; this.errorStore = errorStore; this.globalRetentionSettings = globalRetentionSettings; - this.projectResolver = projectResolver; this.scheduledJob = null; this.pollInterval = DATA_STREAM_LIFECYCLE_POLL_INTERVAL_SETTING.get(settings); this.targetMergePolicyFloorSegment = DATA_STREAM_MERGE_POLICY_TARGET_FLOOR_SEGMENT_SETTING.get(settings); @@ -1074,7 +1070,7 @@ private void rolloverDataStream( rolloverRequest.indicesOptions() ); logger.trace("Data stream lifecycle issues rollover request for data stream [{}]", rolloverRequest.getRolloverTarget()); - projectResolver.projectClient(client, projectId).admin().indices().rolloverIndex(rolloverRequest, new ActionListener<>() { + client.projectClient(projectId).admin().indices().rolloverIndex(rolloverRequest, new ActionListener<>() { @Override public void onResponse(RolloverResponse rolloverResponse) { // Log only when the conditions were met and the index was rolled over. @@ -1137,7 +1133,7 @@ private void updateIndexSetting(ProjectId projectId, UpdateSettingsRequest updat updateSettingsRequest.settings().keySet(), targetIndex ); - projectResolver.projectClient(client, projectId).admin().indices().updateSettings(updateSettingsRequest, new ActionListener<>() { + client.projectClient(projectId).admin().indices().updateSettings(updateSettingsRequest, new ActionListener<>() { @Override public void onResponse(AcknowledgedResponse acknowledgedResponse) { logger.info( @@ -1173,7 +1169,7 @@ private void addIndexBlock(ProjectId projectId, AddIndexBlockRequest addIndexBlo addIndexBlockRequest.getBlock(), targetIndex ); - projectResolver.projectClient(client, projectId).admin().indices().addBlock(addIndexBlockRequest, new ActionListener<>() { + client.projectClient(projectId).admin().indices().addBlock(addIndexBlockRequest, new ActionListener<>() { @Override public void onResponse(AddIndexBlockResponse addIndexBlockResponse) { if (addIndexBlockResponse.isAcknowledged()) { @@ -1252,7 +1248,7 @@ private void deleteIndex(ProjectId projectId, DeleteIndexRequest deleteIndexRequ // "saving" the index name here so we don't capture the entire request String targetIndex = deleteIndexRequest.indices()[0]; logger.trace("Data stream lifecycle issues request to delete index [{}]", targetIndex); - projectResolver.projectClient(client, projectId).admin().indices().delete(deleteIndexRequest, new ActionListener<>() { + client.projectClient(projectId).admin().indices().delete(deleteIndexRequest, new ActionListener<>() { @Override public void onResponse(AcknowledgedResponse acknowledgedResponse) { if (acknowledgedResponse.isAcknowledged()) { @@ -1293,7 +1289,7 @@ private void downsampleIndex(ProjectId projectId, DownsampleAction.Request reque String sourceIndex = request.getSourceIndex(); String downsampleIndex = request.getTargetIndex(); logger.info("Data stream lifecycle issuing request to downsample index [{}] to index [{}]", sourceIndex, downsampleIndex); - projectResolver.projectClient(client, projectId).execute(DownsampleAction.INSTANCE, request, new ActionListener<>() { + client.projectClient(projectId).execute(DownsampleAction.INSTANCE, request, new ActionListener<>() { @Override public void onResponse(AcknowledgedResponse acknowledgedResponse) { assert acknowledgedResponse.isAcknowledged() : "the downsample response is always acknowledged"; @@ -1318,7 +1314,7 @@ private void forceMergeIndex(ProjectId projectId, ForceMergeRequest forceMergeRe : "Data stream lifecycle force merges one index at a time"; final String targetIndex = forceMergeRequest.indices()[0]; logger.info("Data stream lifecycle is issuing a request to force merge index [{}]", targetIndex); - projectResolver.projectClient(client, projectId).admin().indices().forceMerge(forceMergeRequest, new ActionListener<>() { + client.projectClient(projectId).admin().indices().forceMerge(forceMergeRequest, new ActionListener<>() { @Override public void onResponse(BroadcastResponse forceMergeResponse) { if (forceMergeResponse.getFailedShards() > 0) { diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java index c996d89015131..537ee3a008856 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java @@ -182,8 +182,7 @@ public void setupServices() { errorStore, allocationService, new DataStreamLifecycleHealthInfoPublisher(Settings.EMPTY, client, clusterService, errorStore), - globalRetentionSettings, - TestProjectResolvers.mustExecuteFirst() + globalRetentionSettings ); clientDelegate = null; dataStreamLifecycleService.init(); @@ -1456,8 +1455,7 @@ public void testTrackingTimeStats() { errorStore, mock(AllocationService.class), new DataStreamLifecycleHealthInfoPublisher(Settings.EMPTY, getTransportRequestsRecordingClient(), clusterService, errorStore), - globalRetentionSettings, - TestProjectResolvers.mustExecuteFirst() + globalRetentionSettings ); assertThat(service.getLastRunDuration(), is(nullValue())); assertThat(service.getTimeBetweenStarts(), is(nullValue())); @@ -1758,7 +1756,7 @@ private static DiscoveryNode getNode(String nodeId) { * (it does not even notify the listener), but tests can provide an implementation of clientDelegate to provide any needed behavior. */ private Client getTransportRequestsRecordingClient() { - return new NoOpClient(threadPool) { + return new NoOpClient(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())) { @Override protected void doExecute( ActionType action, diff --git a/server/src/main/java/org/elasticsearch/cluster/project/ProjectResolver.java b/server/src/main/java/org/elasticsearch/cluster/project/ProjectResolver.java index b237bca5c2957..f50a7651f842d 100644 --- a/server/src/main/java/org/elasticsearch/cluster/project/ProjectResolver.java +++ b/server/src/main/java/org/elasticsearch/cluster/project/ProjectResolver.java @@ -9,19 +9,12 @@ package org.elasticsearch.cluster.project; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.ActionRequest; -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; -import org.elasticsearch.client.internal.Client; -import org.elasticsearch.client.internal.FilterClient; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ProjectState; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.ProjectId; import org.elasticsearch.cluster.metadata.ProjectMetadata; import org.elasticsearch.core.CheckedRunnable; -import org.elasticsearch.core.FixForMultiProject; import java.util.Collection; import java.util.Objects; @@ -91,26 +84,4 @@ default Collection getProjectIds(ClusterState clusterState) { * It is an error to attempt to override the active project-id */ void executeOnProject(ProjectId projectId, CheckedRunnable body) throws E; - - /** - * Returns a client that executes every request in the context of the given project. - */ - @FixForMultiProject(description = "This recreates a client on every invocation. We should optimize this to be less wasteful") - default Client projectClient(Client baseClient, ProjectId projectId) { - // We only take the shortcut when the given project ID matches the "current" project ID. If it doesn't, we'll let #executeOnProject - // take care of error handling. - if (supportsMultipleProjects() == false && projectId.equals(getProjectId())) { - return baseClient; - } - return new FilterClient(baseClient) { - @Override - protected void doExecute( - ActionType action, - Request request, - ActionListener listener - ) { - executeOnProject(projectId, () -> super.doExecute(action, request, listener)); - } - }; - } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/client/NoOpClient.java b/test/framework/src/main/java/org/elasticsearch/test/client/NoOpClient.java index 03bfe2d2189d9..3536bbc9db356 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/client/NoOpClient.java +++ b/test/framework/src/main/java/org/elasticsearch/test/client/NoOpClient.java @@ -14,6 +14,7 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; import org.elasticsearch.client.internal.support.AbstractClient; +import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -30,6 +31,10 @@ public NoOpClient(ThreadPool threadPool) { super(Settings.EMPTY, threadPool, TestProjectResolvers.alwaysThrow()); } + public NoOpClient(ThreadPool threadPool, ProjectResolver projectResolver) { + super(Settings.EMPTY, threadPool, projectResolver); + } + @Override protected void doExecute( ActionType action, diff --git a/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistry.java b/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistry.java index 8ab9e1e72df27..228ac401b96bb 100644 --- a/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistry.java +++ b/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistry.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.apmdata; import org.elasticsearch.client.internal.Client; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -33,8 +32,7 @@ public APMIndexTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { super( nodeSettings, @@ -42,8 +40,7 @@ public APMIndexTemplateRegistry( threadPool, client, xContentRegistry, - templateFilter(isDataStreamsLifecycleOnlyMode(clusterService.getSettings())), - projectResolver + templateFilter(isDataStreamsLifecycleOnlyMode(clusterService.getSettings())) ); } diff --git a/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMPlugin.java b/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMPlugin.java index 53e3dd90231cc..0be95c337838a 100644 --- a/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMPlugin.java +++ b/x-pack/plugin/apm-data/src/main/java/org/elasticsearch/xpack/apmdata/APMPlugin.java @@ -48,14 +48,7 @@ public Collection createComponents(PluginServices services) { Settings settings = services.environment().settings(); ClusterService clusterService = services.clusterService(); registry.set( - new APMIndexTemplateRegistry( - settings, - clusterService, - services.threadPool(), - services.client(), - services.xContentRegistry(), - services.projectResolver() - ) + new APMIndexTemplateRegistry(settings, clusterService, services.threadPool(), services.client(), services.xContentRegistry()) ); if (enabled) { APMIndexTemplateRegistry registryInstance = registry.get(); diff --git a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java index 2d84d1e11c92e..b18e95b55dde0 100644 --- a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java +++ b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java @@ -11,7 +11,6 @@ import org.elasticsearch.cluster.metadata.DataStreamLifecycle; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeUtils; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; @@ -60,8 +59,7 @@ public void createRegistryAndClient() { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() + NamedXContentRegistry.EMPTY ); apmIndexTemplateRegistry.setEnabled(true); } diff --git a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java index 2338bad220c43..32e7c2225e19d 100644 --- a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java +++ b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java @@ -26,8 +26,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeUtils; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.cluster.project.ProjectResolver; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; @@ -91,9 +89,8 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); client = new VerifyingClient(threadPool); ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool, clusterSettings); - ProjectResolver projectResolver = TestProjectResolvers.mustExecuteFirst(); stackTemplateRegistryAccessor = new StackTemplateRegistryAccessor( - new StackTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY, projectResolver) + new StackTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY) ); apmIndexTemplateRegistry = new APMIndexTemplateRegistry( @@ -101,8 +98,7 @@ public void createRegistryAndClient() { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - projectResolver + NamedXContentRegistry.EMPTY ); apmIndexTemplateRegistry.setEnabled(true); } diff --git a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/VerifyingClient.java b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/VerifyingClient.java index 450a275f6a1c1..e408514dbc60e 100644 --- a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/VerifyingClient.java +++ b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/VerifyingClient.java @@ -11,6 +11,7 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; +import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.common.TriFunction; import org.elasticsearch.test.client.NoOpClient; import org.elasticsearch.threadpool.ThreadPool; @@ -27,7 +28,7 @@ public class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java index 921749ef426a6..7f26a700d29ba 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java @@ -18,7 +18,6 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.ProjectId; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.datastreams.DataStreamsPlugin; import org.elasticsearch.index.mapper.DateFieldMapper; @@ -59,8 +58,7 @@ public void setup() { clusterService.threadPool(), client, xContentRegistry(), - 3L, - TestProjectResolvers.mustExecuteFirst() + 3L ); registry.initialize(); ensureGreen(); diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/RolloverEnabledTestTemplateRegistry.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/RolloverEnabledTestTemplateRegistry.java index b340070c704ae..442ad9a68dfc4 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/RolloverEnabledTestTemplateRegistry.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/RolloverEnabledTestTemplateRegistry.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -29,10 +28,9 @@ public RolloverEnabledTestTemplateRegistry( ThreadPool threadPool, Client client, NamedXContentRegistry xContentRegistry, - long version, - ProjectResolver projectResolver + long version ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); this.version = version; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java index 8c0080e67d759..e48608995d9d4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java @@ -34,7 +34,6 @@ import org.elasticsearch.cluster.metadata.ProjectMetadata; import org.elasticsearch.cluster.metadata.Template; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.regex.Regex; @@ -94,7 +93,6 @@ public abstract class IndexTemplateRegistry implements ClusterStateListener { protected final ConcurrentMap> pipelineCreationsInProgress = new ConcurrentHashMap<>(); protected final List lifecyclePolicies; - protected final ProjectResolver projectResolver; @SuppressWarnings("this-escape") public IndexTemplateRegistry( @@ -102,15 +100,13 @@ public IndexTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { this.settings = nodeSettings; this.client = client; this.threadPool = threadPool; this.xContentRegistry = xContentRegistry; this.clusterService = clusterService; - this.projectResolver = projectResolver; if (isDataStreamsLifecycleOnlyMode(clusterService.getSettings()) == false) { this.lifecyclePolicies = getLifecycleConfigs().stream() .map(config -> config.load(LifecyclePolicyConfig.DEFAULT_X_CONTENT_REGISTRY)) @@ -507,7 +503,7 @@ public void onFailure(Exception e) { onPutTemplateFailure(templateName, e); } }, - projectResolver.projectClient(client, projectId).admin().indices()::putTemplate + client.projectClient(projectId).admin().indices()::putTemplate ); }); } @@ -545,8 +541,7 @@ public void onFailure(Exception e) { onPutTemplateFailure(templateName, e); } }, - (req, listener) -> projectResolver.projectClient(client, projectId) - .execute(PutComponentTemplateAction.INSTANCE, req, listener) + (req, listener) -> client.projectClient(projectId).execute(PutComponentTemplateAction.INSTANCE, req, listener) ); }); } @@ -591,8 +586,7 @@ public void onFailure(Exception e) { onPutTemplateFailure(templateName, e); } }, - (req, listener) -> projectResolver.projectClient(client, project.id()) - .execute(TransportPutComposableIndexTemplateAction.TYPE, req, listener) + (req, listener) -> client.projectClient(project.id()).execute(TransportPutComposableIndexTemplateAction.TYPE, req, listener) ); }); } @@ -662,7 +656,7 @@ public void onFailure(Exception e) { onPutPolicyFailure(policy, e); } }, - (req, listener) -> projectResolver.projectClient(client, projectId).execute(ILMActions.PUT, req, listener) + (req, listener) -> client.projectClient(projectId).execute(ILMActions.PUT, req, listener) ); }); } @@ -776,7 +770,7 @@ public void onFailure(Exception e) { onPutPipelineFailure(pipelineConfig.getId(), e); } }, - (req, listener) -> projectResolver.projectClient(client, projectId).execute(PutPipelineTransportAction.TYPE, req, listener) + (req, listener) -> client.projectClient(projectId).execute(PutPipelineTransportAction.TYPE, req, listener) ); }); } @@ -851,7 +845,7 @@ public void onFailure(Exception e) { getOrigin(), request, groupedActionListener, - (req, listener) -> projectResolver.projectClient(client, project.id()).execute(RolloverAction.INSTANCE, req, listener) + (req, listener) -> client.projectClient(project.id()).execute(RolloverAction.INSTANCE, req, listener) ); } }); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java index 5fd7acf039511..cf0a73963f864 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java @@ -13,7 +13,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; @@ -55,10 +54,9 @@ public YamlTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - this(nodeSettings, clusterService, threadPool, client, xContentRegistry, ignored -> true, projectResolver); + this(nodeSettings, clusterService, threadPool, client, xContentRegistry, ignored -> true); } @SuppressWarnings({ "unchecked", "this-escape" }) @@ -68,10 +66,9 @@ public YamlTemplateRegistry( ThreadPool threadPool, Client client, NamedXContentRegistry xContentRegistry, - Predicate templateFilter, - ProjectResolver projectResolver + Predicate templateFilter ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); try { final Map resources = XContentHelper.convertToMap( YamlXContent.yamlXContent, diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryTests.java index 7d4757cb2e55d..086a7b20745cc 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryTests.java @@ -97,14 +97,7 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); client = new VerifyingClient(threadPool); clusterService = ClusterServiceUtils.createClusterService(threadPool); - registry = new TestRegistryWithCustomPlugin( - Settings.EMPTY, - clusterService, - threadPool, - client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext()) - ); + registry = new TestRegistryWithCustomPlugin(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY); } @After @@ -942,7 +935,7 @@ public static class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/TestRegistryWithCustomPlugin.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/TestRegistryWithCustomPlugin.java index bc3ea9ed445a9..f3f3157a7a0f0 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/TestRegistryWithCustomPlugin.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/template/TestRegistryWithCustomPlugin.java @@ -12,7 +12,6 @@ import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; import org.elasticsearch.cluster.metadata.ProjectId; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -48,10 +47,9 @@ class TestRegistryWithCustomPlugin extends IndexTemplateRegistry { ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); this.threadPool = threadPool; } diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java index 36312964dc65f..fc289553296ad 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java @@ -85,8 +85,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); templateRegistry.initialize(); diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingTemplateRegistry.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingTemplateRegistry.java index ae995aca06c09..4e5f75461316d 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingTemplateRegistry.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingTemplateRegistry.java @@ -10,7 +10,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -50,10 +49,9 @@ public DeprecationIndexingTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); } private static final Map COMPONENT_TEMPLATE_CONFIGS; diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/EnterpriseSearch.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/EnterpriseSearch.java index 1cdba56db96bf..c9cfd2aae9e3d 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/EnterpriseSearch.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/EnterpriseSearch.java @@ -476,8 +476,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); analyticsTemplateRegistry.initialize(); @@ -486,8 +485,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); connectorTemplateRegistry.initialize(); diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistry.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistry.java index 1ef2846f86d54..18a335378efba 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistry.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistry.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.UpdateForV10; @@ -106,10 +105,9 @@ public AnalyticsTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry); } @Override diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistry.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistry.java index 771507fb69901..fd35acc89db5c 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistry.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistry.java @@ -10,7 +10,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -145,10 +144,9 @@ public ConnectorTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry); } @Override diff --git a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistryTests.java b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistryTests.java index 8a1fc5e79bf6b..7d4b6290cc587 100644 --- a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistryTests.java +++ b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/AnalyticsTemplateRegistryTests.java @@ -76,13 +76,7 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); client = new VerifyingClient(threadPool); ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool); - registry = new AnalyticsTemplateRegistry( - clusterService, - threadPool, - client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() - ); + registry = new AnalyticsTemplateRegistry(clusterService, threadPool, client, NamedXContentRegistry.EMPTY); } @After @@ -293,7 +287,7 @@ public static class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistryTests.java b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistryTests.java index b45c1fbd8f6b7..f5aef4663b8cb 100644 --- a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistryTests.java +++ b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/connector/ConnectorTemplateRegistryTests.java @@ -79,13 +79,7 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); client = new VerifyingClient(threadPool); ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool); - registry = new ConnectorTemplateRegistry( - clusterService, - threadPool, - client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() - ); + registry = new ConnectorTemplateRegistry(clusterService, threadPool, client, NamedXContentRegistry.EMPTY); } @After @@ -317,7 +311,7 @@ private static class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java b/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java index ea95cbca11047..c2a5fe1ebb782 100644 --- a/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java +++ b/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java @@ -95,8 +95,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); registry.initialize(); return List.of(); diff --git a/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/FleetTemplateRegistry.java b/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/FleetTemplateRegistry.java index 9e197e991edb9..6585553a1bd9d 100644 --- a/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/FleetTemplateRegistry.java +++ b/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/FleetTemplateRegistry.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -68,10 +67,9 @@ public FleetTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); } @Override diff --git a/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java b/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java index 14445848a3b99..75c5c21db1bdd 100644 --- a/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java +++ b/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java @@ -235,8 +235,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); indexTemplateRegistry.initialize(); return List.of(indexTemplateRegistry); diff --git a/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java b/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java index 80b1bb8c01229..bc94d48e9baea 100644 --- a/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java +++ b/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/IdentityProviderPlugin.java @@ -84,8 +84,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); indexTemplateRegistry.initialize(); diff --git a/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTemplateRegistry.java b/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTemplateRegistry.java index 1e51750a279f6..bd6bdbabbd4f2 100644 --- a/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTemplateRegistry.java +++ b/x-pack/plugin/identity-provider/src/main/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTemplateRegistry.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.idp.saml.sp; import org.elasticsearch.client.internal.Client; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -32,10 +31,9 @@ public SamlServiceProviderIndexTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java index 429b03c9cf8c5..6038f6ddb1b0f 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java @@ -146,8 +146,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); ilmTemplateRegistry.initialize(); ilmHistoryStore.set( diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java index 6411d13bad86e..5633033e6faa1 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -56,10 +55,9 @@ public ILMHistoryTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); this.ilmHistoryEnabled = LifecycleSettings.LIFECYCLE_HISTORY_INDEX_ENABLED_SETTING.get(nodeSettings); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStoreTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStoreTests.java index ffa05403345fb..1797f6b10f3cb 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStoreTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStoreTests.java @@ -25,7 +25,6 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; import org.elasticsearch.cluster.metadata.Metadata; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.TriFunction; import org.elasticsearch.common.settings.ClusterSettings; @@ -81,8 +80,7 @@ public void setup() { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() + NamedXContentRegistry.EMPTY ); ClusterState state = clusterService.state(); ClusterServiceUtils.setState( diff --git a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigratePlugin.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigratePlugin.java index 50ee8885ed112..6d5172756f55b 100644 --- a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigratePlugin.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigratePlugin.java @@ -89,8 +89,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); registry.initialize(); return List.of(registry); diff --git a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigrateTemplateRegistry.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigrateTemplateRegistry.java index 752404461df0f..2a9dc97e16352 100644 --- a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigrateTemplateRegistry.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/MigrateTemplateRegistry.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.migrate; import org.elasticsearch.client.internal.Client; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -32,10 +31,9 @@ public MigrateTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java index 6a17ad073a7f2..0c8cec2c8d218 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java @@ -978,8 +978,7 @@ public Collection createComponents(PluginServices services) { threadPool, client, machineLearningExtension.get().useIlm(), - xContentRegistry, - services.projectResolver() + xContentRegistry ); registry.initialize(); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistry.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistry.java index 3ddb7074adb10..02fcc2b4465f3 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistry.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistry.java @@ -8,7 +8,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -127,10 +126,9 @@ public MlIndexTemplateRegistry( ThreadPool threadPool, Client client, boolean useIlm, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); this.useIlm = useIlm; this.composableIndexTemplateConfigs = parseComposableTemplates( anomalyDetectionResultsTemplate(), diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistryTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistryTests.java index bd5c72fb789fb..3462ba6c44ca2 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistryTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlIndexTemplateRegistryTests.java @@ -20,7 +20,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeUtils; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.CollectionUtils; @@ -66,6 +65,7 @@ public void setUpMocks() { client = mock(Client.class); when(client.threadPool()).thenReturn(threadPool); + when(client.projectClient(any())).thenReturn(client); AdminClient adminClient = mock(AdminClient.class); IndicesAdminClient indicesAdminClient = mock(IndicesAdminClient.class); when(adminClient.indices()).thenReturn(indicesAdminClient); @@ -92,8 +92,7 @@ public void testStateTemplate() { threadPool, client, true, - xContentRegistry, - TestProjectResolvers.mustExecuteFirst() + xContentRegistry ); registry.clusterChanged(createClusterChangedEvent(nodes)); @@ -121,8 +120,7 @@ public void testStatsTemplate() { threadPool, client, false, - xContentRegistry, - TestProjectResolvers.mustExecuteFirst() + xContentRegistry ); registry.clusterChanged(createClusterChangedEvent(nodes)); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java index 4a5257f44f5ff..179955b3722fb 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java @@ -162,8 +162,7 @@ public Collection createComponents(PluginServices services) { clusterService, threadPool, client, - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); templateRegistry.initialize(); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistry.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistry.java index 0c8bce6096c5d..6a76d6749489a 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistry.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistry.java @@ -11,7 +11,6 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -244,10 +243,9 @@ public MonitoringTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); this.clusterService = clusterService; this.monitoringTemplatesEnabled = MONITORING_TEMPLATES_ENABLED.get(nodeSettings); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistryTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistryTests.java index 97ddfee77c998..3e616797a9f82 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistryTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTemplateRegistryTests.java @@ -83,14 +83,7 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); client = new VerifyingClient(threadPool); clusterService = ClusterServiceUtils.createClusterService(threadPool); - registry = new MonitoringTemplateRegistry( - Settings.EMPTY, - clusterService, - threadPool, - client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() - ); + registry = new MonitoringTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY); } @After @@ -123,8 +116,7 @@ public void testDisabledDoesNotAddTemplates() { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() + NamedXContentRegistry.EMPTY ); assertThat(disabledRegistry.getLegacyTemplateConfigs(), is(empty())); assertThat(disabledRegistry.getComposableTemplateConfigs(), anEmptyMap()); @@ -203,8 +195,7 @@ public void testThatNonExistingPoliciesAreAddedImmediately() throws Exception { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() + NamedXContentRegistry.EMPTY ); testRegistry.clusterChanged(event); } else { @@ -329,7 +320,7 @@ public static class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelIndexTemplateRegistry.java b/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelIndexTemplateRegistry.java index 2ac4e2c4b54df..ca52db9331cf3 100644 --- a/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelIndexTemplateRegistry.java +++ b/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelIndexTemplateRegistry.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.oteldata; import org.elasticsearch.client.internal.Client; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -27,10 +26,9 @@ public OTelIndexTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); } @Override diff --git a/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelPlugin.java b/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelPlugin.java index 26531f7669771..67bd8c4e002d3 100644 --- a/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelPlugin.java +++ b/x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/OTelPlugin.java @@ -48,14 +48,7 @@ public Collection createComponents(PluginServices services) { Settings settings = services.environment().settings(); ClusterService clusterService = services.clusterService(); registry.set( - new OTelIndexTemplateRegistry( - settings, - clusterService, - services.threadPool(), - services.client(), - services.xContentRegistry(), - services.projectResolver() - ) + new OTelIndexTemplateRegistry(settings, clusterService, services.threadPool(), services.client(), services.xContentRegistry()) ); if (enabled) { OTelIndexTemplateRegistry registryInstance = registry.get(); diff --git a/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/ProfilingPlugin.java b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/ProfilingPlugin.java index c44332d4068be..4c02c802f18d6 100644 --- a/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/ProfilingPlugin.java +++ b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/ProfilingPlugin.java @@ -97,16 +97,7 @@ public Collection createComponents(PluginServices services) { ThreadPool threadPool = services.threadPool(); logger.info("Profiling is {}", enabled ? "enabled" : "disabled"); - registry.set( - new ProfilingIndexTemplateRegistry( - settings, - clusterService, - threadPool, - client, - services.xContentRegistry(), - services.projectResolver() - ) - ); + registry.set(new ProfilingIndexTemplateRegistry(settings, clusterService, threadPool, client, services.xContentRegistry())); indexStateResolver.set(new IndexStateResolver(PROFILING_CHECK_OUTDATED_INDICES.get(settings))); clusterService.getClusterSettings().addSettingsUpdateConsumer(PROFILING_CHECK_OUTDATED_INDICES, this::updateCheckOutdatedIndices); diff --git a/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistry.java b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistry.java index f30fe205d2eba..76e5720552d35 100644 --- a/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistry.java +++ b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistry.java @@ -13,7 +13,6 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -80,10 +79,9 @@ public ProfilingIndexTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); } public void setTemplatesEnabled(boolean templatesEnabled) { diff --git a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistryTests.java b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistryTests.java index 3224c2e3a1d0c..81d6ed15804b6 100644 --- a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistryTests.java +++ b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/ProfilingIndexTemplateRegistryTests.java @@ -25,7 +25,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeUtils; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ClusterServiceUtils; @@ -77,14 +76,7 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); client = new VerifyingClient(threadPool); clusterService = ClusterServiceUtils.createClusterService(threadPool); - registry = new ProfilingIndexTemplateRegistry( - Settings.EMPTY, - clusterService, - threadPool, - client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() - ); + registry = new ProfilingIndexTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY); registry.setTemplatesEnabled(true); } diff --git a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/VerifyingClient.java b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/VerifyingClient.java index 38a0c2fdf7e10..7683a320d5861 100644 --- a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/VerifyingClient.java +++ b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/persistence/VerifyingClient.java @@ -11,6 +11,7 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; +import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.common.TriFunction; import org.elasticsearch.test.client.NoOpClient; import org.elasticsearch.threadpool.ThreadPool; @@ -27,7 +28,7 @@ class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java index e65a3d6b41910..1e4048507f140 100644 --- a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java +++ b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycle.java @@ -127,8 +127,7 @@ public Collection createComponents(PluginServices services) { clusterService, threadPool, client, - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); templateRegistry.initialize(); snapshotHistoryStore.set(new SnapshotHistoryStore(new OriginSettingClient(client, INDEX_LIFECYCLE_ORIGIN), clusterService)); diff --git a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistry.java b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistry.java index caca0b198a076..9757b0c55db76 100644 --- a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistry.java +++ b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistry.java @@ -10,7 +10,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -63,10 +62,9 @@ public SnapshotLifecycleTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); slmHistoryEnabled = SLM_HISTORY_INDEX_ENABLED_SETTING.get(nodeSettings); } diff --git a/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistryTests.java b/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistryTests.java index 8f0ad858f77c0..c572f2adf9bca 100644 --- a/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistryTests.java +++ b/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotLifecycleTemplateRegistryTests.java @@ -101,14 +101,7 @@ public void createRegistryAndClient() { ) ); xContentRegistry = new NamedXContentRegistry(entries); - registry = new SnapshotLifecycleTemplateRegistry( - Settings.EMPTY, - clusterService, - threadPool, - client, - xContentRegistry, - TestProjectResolvers.mustExecuteFirst() - ); + registry = new SnapshotLifecycleTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry); } @After @@ -125,8 +118,7 @@ public void testDisabledDoesNotAddTemplates() { clusterService, threadPool, client, - xContentRegistry, - TestProjectResolvers.mustExecuteFirst() + xContentRegistry ); assertThat(disabledRegistry.getComposableTemplateConfigs(), anEmptyMap()); assertThat(disabledRegistry.getLifecyclePolicies(), hasSize(0)); @@ -345,7 +337,7 @@ public static class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java index 5404199299eaf..c89a8237d40b7 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java @@ -12,7 +12,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -92,10 +91,9 @@ public LegacyStackTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); this.clusterService = clusterService; this.stackTemplateEnabled = STACK_TEMPLATES_ENABLED.get(nodeSettings); } diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackPlugin.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackPlugin.java index 3abe06165c22d..73c18a3cc2619 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackPlugin.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackPlugin.java @@ -33,8 +33,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); legacyStackTemplateRegistry.initialize(); StackTemplateRegistry stackTemplateRegistry = new StackTemplateRegistry( @@ -42,8 +41,7 @@ public Collection createComponents(PluginServices services) { services.clusterService(), services.threadPool(), services.client(), - services.xContentRegistry(), - services.projectResolver() + services.xContentRegistry() ); stackTemplateRegistry.initialize(); return List.of(legacyStackTemplateRegistry, stackTemplateRegistry); diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java index 4a2d3e2e228de..a2f8dd91176e2 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java @@ -12,7 +12,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -119,10 +118,9 @@ public StackTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); this.clusterService = clusterService; this.stackTemplateEnabled = STACK_TEMPLATES_ENABLED.get(nodeSettings); this.componentTemplateConfigs = loadComponentTemplateConfigs(); diff --git a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java index 5e0b2b321a20f..654cf494e0e6f 100644 --- a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java +++ b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.ingest.PipelineConfiguration; @@ -34,14 +33,7 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); Client client = new NoOpClient(threadPool); ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool); - registry = new LegacyStackTemplateRegistry( - Settings.EMPTY, - clusterService, - threadPool, - client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() - ); + registry = new LegacyStackTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY); } @After diff --git a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackRegistryWithNonRequiredTemplates.java b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackRegistryWithNonRequiredTemplates.java index 553b7ad80f43a..7f674e24658dd 100644 --- a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackRegistryWithNonRequiredTemplates.java +++ b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackRegistryWithNonRequiredTemplates.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -24,10 +23,9 @@ class StackRegistryWithNonRequiredTemplates extends StackTemplateRegistry { ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); } @Override diff --git a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java index 313b8d24bd34f..2c95afc5b8d9b 100644 --- a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java +++ b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java @@ -85,14 +85,7 @@ public void createRegistryAndClient() { threadPool = new TestThreadPool(this.getClass().getName()); client = new VerifyingClient(threadPool); clusterService = ClusterServiceUtils.createClusterService(threadPool); - registry = new StackTemplateRegistry( - Settings.EMPTY, - clusterService, - threadPool, - client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() - ); + registry = new StackTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY); } @After @@ -109,8 +102,7 @@ public void testDisabledDoesNotAddIndexTemplates() { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() + NamedXContentRegistry.EMPTY ); assertThat(disabledRegistry.getComposableTemplateConfigs(), anEmptyMap()); } @@ -122,8 +114,7 @@ public void testDisabledStillAddsComponentTemplatesAndIlmPolicies() { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() + NamedXContentRegistry.EMPTY ); assertThat(disabledRegistry.getComponentTemplateConfigs(), not(anEmptyMap())); assertThat( @@ -367,8 +358,7 @@ public void testMissingNonRequiredTemplates() throws Exception { clusterService, threadPool, client, - NamedXContentRegistry.EMPTY, - TestProjectResolvers.mustExecuteFirst() + NamedXContentRegistry.EMPTY ); DiscoveryNode node = DiscoveryNodeUtils.create("node"); @@ -555,7 +545,7 @@ public static class VerifyingClient extends NoOpClient { }; VerifyingClient(ThreadPool threadPool) { - super(threadPool); + super(threadPool, TestProjectResolvers.usingRequestHeader(threadPool.getThreadContext())); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index f6b2370239c58..68cf0984d3808 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -342,8 +342,7 @@ public Collection createComponents(PluginServices services) { clusterService, threadPool, client, - xContentRegistry, - services.projectResolver() + xContentRegistry ); templateRegistry.initialize(); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java index 5dd7c242dc365..dca1f2bbc56ce 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -38,10 +37,9 @@ public WatcherIndexTemplateRegistry( ClusterService clusterService, ThreadPool threadPool, Client client, - NamedXContentRegistry xContentRegistry, - ProjectResolver projectResolver + NamedXContentRegistry xContentRegistry ) { - super(nodeSettings, clusterService, threadPool, client, xContentRegistry, projectResolver); + super(nodeSettings, clusterService, threadPool, client, xContentRegistry); ilmManagementEnabled = Watcher.USE_ILM_INDEX_MANAGEMENT.get(nodeSettings); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java index 581704036740d..6c88380a88c68 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -24,8 +24,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeUtils; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.cluster.project.ProjectResolver; -import org.elasticsearch.cluster.project.TestProjectResolvers; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.EsExecutors; @@ -82,7 +80,6 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { private ClusterService clusterService; private ThreadPool threadPool; private Client client; - private ProjectResolver projectResolver; @SuppressWarnings("unchecked") @Before @@ -93,6 +90,7 @@ public void createRegistryAndClient() { client = mock(Client.class); when(client.threadPool()).thenReturn(threadPool); + when(client.projectClient(any())).thenReturn(client); AdminClient adminClient = mock(AdminClient.class); IndicesAdminClient indicesAdminClient = mock(IndicesAdminClient.class); when(adminClient.indices()).thenReturn(indicesAdminClient); @@ -117,8 +115,7 @@ public void createRegistryAndClient() { ) ); xContentRegistry = new NamedXContentRegistry(entries); - projectResolver = TestProjectResolvers.mustExecuteFirst(); - registry = new WatcherIndexTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry, projectResolver); + registry = new WatcherIndexTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry); } public void testThatNonExistingTemplatesAreAddedImmediately() { @@ -156,8 +153,7 @@ public void testThatNonExistingTemplatesAreAddedEvenWithILMUsageDisabled() { clusterService, threadPool, client, - xContentRegistry, - projectResolver + xContentRegistry ); ClusterChangedEvent event = createClusterChangedEvent(Settings.EMPTY, Collections.emptyMap(), Collections.emptyMap(), nodes); registry.clusterChanged(event); @@ -209,8 +205,7 @@ public void testNoPolicyButILMDisabled() { clusterService, threadPool, client, - xContentRegistry, - projectResolver + xContentRegistry ); ClusterChangedEvent event = createClusterChangedEvent(Settings.EMPTY, Collections.emptyMap(), Collections.emptyMap(), nodes); registry.clusterChanged(event);