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.
This commit is contained in:
parent
2db2b945ec
commit
0d12ef8958
|
@ -50,6 +50,7 @@ public final class ClientHelper {
|
|||
public static final String DEPRECATION_ORIGIN = "deprecation";
|
||||
public static final String PERSISTENT_TASK_ORIGIN = "persistent_tasks";
|
||||
public static final String ROLLUP_ORIGIN = "rollup";
|
||||
public static final String ENRICH_ORIGIN = "enrich";
|
||||
public static final String TRANSFORM_ORIGIN = "transform";
|
||||
|
||||
private ClientHelper() {}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
|
|||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.OriginSettingClient;
|
||||
import org.elasticsearch.cluster.LocalNodeMasterListener;
|
||||
import org.elasticsearch.cluster.metadata.AliasMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
|
@ -34,6 +35,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import static org.elasticsearch.xpack.core.ClientHelper.ENRICH_ORIGIN;
|
||||
|
||||
public class EnrichPolicyMaintenanceService implements LocalNodeMasterListener {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(EnrichPolicyMaintenanceService.class);
|
||||
|
@ -54,7 +57,7 @@ public class EnrichPolicyMaintenanceService implements LocalNodeMasterListener {
|
|||
EnrichPolicyMaintenanceService(Settings settings, Client client, ClusterService clusterService, ThreadPool threadPool,
|
||||
EnrichPolicyLocks enrichPolicyLocks) {
|
||||
this.settings = settings;
|
||||
this.client = client;
|
||||
this.client = new OriginSettingClient(client, ENRICH_ORIGIN);
|
||||
this.clusterService = clusterService;
|
||||
this.threadPool = threadPool;
|
||||
this.enrichPolicyLocks = enrichPolicyLocks;
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.function.Consumer;
|
|||
import java.util.function.Predicate;
|
||||
|
||||
import static org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskAction.TASKS_ORIGIN;
|
||||
import static org.elasticsearch.xpack.core.ClientHelper.ENRICH_ORIGIN;
|
||||
import static org.elasticsearch.xpack.core.ClientHelper.TRANSFORM_ORIGIN;
|
||||
import static org.elasticsearch.xpack.core.ClientHelper.DEPRECATION_ORIGIN;
|
||||
import static org.elasticsearch.xpack.core.ClientHelper.INDEX_LIFECYCLE_ORIGIN;
|
||||
|
@ -111,6 +112,7 @@ public final class AuthorizationUtils {
|
|||
case PERSISTENT_TASK_ORIGIN:
|
||||
case ROLLUP_ORIGIN:
|
||||
case INDEX_LIFECYCLE_ORIGIN:
|
||||
case ENRICH_ORIGIN:
|
||||
case TASKS_ORIGIN: // TODO use a more limited user for tasks
|
||||
securityContext.executeAsUser(XPackUser.INSTANCE, consumer, Version.CURRENT);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue