Skip to content

Commit 2b36a80

Browse files
committed
Add Enrich Origin (elastic#48098)
This PR adds an origin for the Enrich feature, and modifies the background maintenance task to use the origin when executing client operations. Without this fix, the maintenance task fails to execute when security is enabled.
1 parent 1782047 commit 2b36a80

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ClientHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public final class ClientHelper {
5050
public static final String DEPRECATION_ORIGIN = "deprecation";
5151
public static final String PERSISTENT_TASK_ORIGIN = "persistent_tasks";
5252
public static final String ROLLUP_ORIGIN = "rollup";
53+
public static final String ENRICH_ORIGIN = "enrich";
5354
public static final String TRANSFORM_ORIGIN = "transform";
5455

5556
private ClientHelper() {}

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyMaintenanceService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.action.support.IndicesOptions;
1515
import org.elasticsearch.action.support.master.AcknowledgedResponse;
1616
import org.elasticsearch.client.Client;
17+
import org.elasticsearch.client.OriginSettingClient;
1718
import org.elasticsearch.cluster.LocalNodeMasterListener;
1819
import org.elasticsearch.cluster.metadata.AliasMetaData;
1920
import org.elasticsearch.cluster.metadata.MappingMetaData;
@@ -34,6 +35,8 @@
3435
import java.util.Map;
3536
import java.util.concurrent.Semaphore;
3637

38+
import static org.elasticsearch.xpack.core.ClientHelper.ENRICH_ORIGIN;
39+
3740
public class EnrichPolicyMaintenanceService implements LocalNodeMasterListener {
3841

3942
private static final Logger logger = LogManager.getLogger(EnrichPolicyMaintenanceService.class);
@@ -54,7 +57,7 @@ public class EnrichPolicyMaintenanceService implements LocalNodeMasterListener {
5457
EnrichPolicyMaintenanceService(Settings settings, Client client, ClusterService clusterService, ThreadPool threadPool,
5558
EnrichPolicyLocks enrichPolicyLocks) {
5659
this.settings = settings;
57-
this.client = client;
60+
this.client = new OriginSettingClient(client, ENRICH_ORIGIN);
5861
this.clusterService = clusterService;
5962
this.threadPool = threadPool;
6063
this.enrichPolicyLocks = enrichPolicyLocks;

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.function.Predicate;
2020

2121
import static org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskAction.TASKS_ORIGIN;
22+
import static org.elasticsearch.xpack.core.ClientHelper.ENRICH_ORIGIN;
2223
import static org.elasticsearch.xpack.core.ClientHelper.TRANSFORM_ORIGIN;
2324
import static org.elasticsearch.xpack.core.ClientHelper.DEPRECATION_ORIGIN;
2425
import static org.elasticsearch.xpack.core.ClientHelper.INDEX_LIFECYCLE_ORIGIN;
@@ -111,6 +112,7 @@ public static void switchUserBasedOnActionOriginAndExecute(ThreadContext threadC
111112
case PERSISTENT_TASK_ORIGIN:
112113
case ROLLUP_ORIGIN:
113114
case INDEX_LIFECYCLE_ORIGIN:
115+
case ENRICH_ORIGIN:
114116
case TASKS_ORIGIN: // TODO use a more limited user for tasks
115117
securityContext.executeAsUser(XPackUser.INSTANCE, consumer, Version.CURRENT);
116118
break;

0 commit comments

Comments
 (0)