Skip to content

Commit ef5755b

Browse files
authored
Add Enrich Origin (#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 b2b9a59 commit ef5755b

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;
@@ -32,6 +33,8 @@
3233
import java.util.Map;
3334
import java.util.concurrent.Semaphore;
3435

36+
import static org.elasticsearch.xpack.core.ClientHelper.ENRICH_ORIGIN;
37+
3538
public class EnrichPolicyMaintenanceService implements LocalNodeMasterListener {
3639

3740
private static final Logger logger = LogManager.getLogger(EnrichPolicyMaintenanceService.class);
@@ -52,7 +55,7 @@ public class EnrichPolicyMaintenanceService implements LocalNodeMasterListener {
5255
EnrichPolicyMaintenanceService(Settings settings, Client client, ClusterService clusterService, ThreadPool threadPool,
5356
EnrichPolicyLocks enrichPolicyLocks) {
5457
this.settings = settings;
55-
this.client = client;
58+
this.client = new OriginSettingClient(client, ENRICH_ORIGIN);
5659
this.clusterService = clusterService;
5760
this.threadPool = threadPool;
5861
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)