Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [ML] ensure tasks API executes through ML_ORIGIN (#75880) #75887

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.OriginSettingClient;
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
Expand Down Expand Up @@ -50,7 +51,6 @@

import static org.elasticsearch.ExceptionsHelper.rethrowAndSuppress;
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
import static org.elasticsearch.xpack.core.ml.MlTasks.AWAITING_UPGRADE;
import static org.elasticsearch.xpack.core.ml.MlTasks.DATAFEED_TASK_NAME;
import static org.elasticsearch.xpack.core.ml.MlTasks.JOB_TASK_NAME;
Expand All @@ -67,7 +67,7 @@ public class TransportSetUpgradeModeAction extends AcknowledgedTransportMasterNo
private final PersistentTasksClusterService persistentTasksClusterService;
private final PersistentTasksService persistentTasksService;
private final ClusterService clusterService;
private final Client client;
private final OriginSettingClient client;

@Inject
public TransportSetUpgradeModeAction(TransportService transportService, ThreadPool threadPool, ClusterService clusterService,
Expand All @@ -78,7 +78,7 @@ public TransportSetUpgradeModeAction(TransportService transportService, ThreadPo
indexNameExpressionResolver, ThreadPool.Names.SAME);
this.persistentTasksClusterService = persistentTasksClusterService;
this.clusterService = clusterService;
this.client = client;
this.client = new OriginSettingClient(client, ML_ORIGIN);
this.persistentTasksService = persistentTasksService;
}

Expand Down Expand Up @@ -289,7 +289,7 @@ private void isolateDatafeeds(PersistentTasksCustomMetadata tasksCustomMetadata,
datafeedsToIsolate.forEach(datafeedId -> {
IsolateDatafeedAction.Request isolationRequest = new IsolateDatafeedAction.Request(datafeedId);
isolateDatafeedsExecutor.add(isolateListener ->
executeAsyncWithOrigin(client, ML_ORIGIN, IsolateDatafeedAction.INSTANCE, isolationRequest, isolateListener)
client.execute(IsolateDatafeedAction.INSTANCE, isolationRequest, isolateListener)
);
});

Expand Down