Make IndexTemplateRegistry project-aware (#126986)

Ensures the `IndexTemplatesRegistry` installs resources in every project
in the cluster.

ES-10055
This commit is contained in:
Niels Bauman 2025-04-24 12:22:18 +02:00 committed by GitHub
parent 7b95ec4767
commit ff1c9b7c6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 549 additions and 289 deletions

View file

@ -469,7 +469,8 @@ public class EnterpriseSearch extends Plugin implements ActionPlugin, SystemInde
services.clusterService(),
services.threadPool(),
services.client(),
services.xContentRegistry()
services.xContentRegistry(),
services.projectResolver()
);
analyticsTemplateRegistry.initialize();
@ -478,7 +479,8 @@ public class EnterpriseSearch extends Plugin implements ActionPlugin, SystemInde
services.clusterService(),
services.threadPool(),
services.client(),
services.xContentRegistry()
services.xContentRegistry(),
services.projectResolver()
);
connectorTemplateRegistry.initialize();

View file

@ -9,6 +9,7 @@ package org.elasticsearch.xpack.application.analytics;
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;
@ -105,9 +106,10 @@ public class AnalyticsTemplateRegistry extends IndexTemplateRegistry {
ClusterService clusterService,
ThreadPool threadPool,
Client client,
NamedXContentRegistry xContentRegistry
NamedXContentRegistry xContentRegistry,
ProjectResolver projectResolver
) {
super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry);
super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry, projectResolver);
}
@Override

View file

@ -10,6 +10,7 @@ package org.elasticsearch.xpack.application.connector;
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;
@ -144,9 +145,10 @@ public class ConnectorTemplateRegistry extends IndexTemplateRegistry {
ClusterService clusterService,
ThreadPool threadPool,
Client client,
NamedXContentRegistry xContentRegistry
NamedXContentRegistry xContentRegistry,
ProjectResolver projectResolver
) {
super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry);
super(Settings.EMPTY, clusterService, threadPool, client, xContentRegistry, projectResolver);
}
@Override

View file

@ -25,6 +25,7 @@ import org.elasticsearch.cluster.metadata.Metadata;
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.TriFunction;
import org.elasticsearch.common.bytes.BytesArray;
@ -75,7 +76,13 @@ public class AnalyticsTemplateRegistryTests extends ESTestCase {
threadPool = new TestThreadPool(this.getClass().getName());
client = new VerifyingClient(threadPool);
ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
registry = new AnalyticsTemplateRegistry(clusterService, threadPool, client, NamedXContentRegistry.EMPTY);
registry = new AnalyticsTemplateRegistry(
clusterService,
threadPool,
client,
NamedXContentRegistry.EMPTY,
TestProjectResolvers.mustExecuteFirst()
);
}
@After

View file

@ -25,6 +25,7 @@ import org.elasticsearch.cluster.metadata.Metadata;
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.TriFunction;
import org.elasticsearch.common.bytes.BytesArray;
@ -78,7 +79,13 @@ public class ConnectorTemplateRegistryTests extends ESTestCase {
threadPool = new TestThreadPool(this.getClass().getName());
client = new VerifyingClient(threadPool);
ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
registry = new ConnectorTemplateRegistry(clusterService, threadPool, client, NamedXContentRegistry.EMPTY);
registry = new ConnectorTemplateRegistry(
clusterService,
threadPool,
client,
NamedXContentRegistry.EMPTY,
TestProjectResolvers.mustExecuteFirst()
);
}
@After