Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions docs/changelog/135484.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 135484
summary: Add origin to client in SLM task
area: ILM+SLM
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
import org.elasticsearch.action.admin.cluster.snapshots.get.TransportGetSnapshotsAction;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.client.internal.OriginSettingClient;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.ProjectState;
Expand Down Expand Up @@ -79,7 +80,7 @@ public SnapshotLifecycleTask(
final SnapshotHistoryStore historyStore
) {
this.projectId = projectId;
this.client = client;
this.client = new OriginSettingClient(client, ClientHelper.INDEX_LIFECYCLE_ORIGIN);
this.clusterService = clusterService;
this.historyStore = historyStore;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.xpack.slm;

import org.apache.lucene.util.SetOnce;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
Expand All @@ -31,6 +32,7 @@
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.test.ClusterServiceUtils;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.client.NoOpClient;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
Expand Down Expand Up @@ -129,7 +131,7 @@ public void testNothingScheduledWhenNotRunning() throws InterruptedException {
ClusterService clusterService = ClusterServiceUtils.createClusterService(initialState, threadPool);
SnapshotLifecycleService sls = new SnapshotLifecycleService(
Settings.EMPTY,
(projectId) -> new FakeSnapshotTask(e -> logger.info("triggered")),
(projectId) -> new FakeSnapshotTask(e -> logger.info("triggered"), new NoOpClient(threadPool)),
clusterService,
clock
)
Expand Down Expand Up @@ -198,7 +200,7 @@ public void testPolicyCRUD() throws Exception {
ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
SnapshotLifecycleService sls = new SnapshotLifecycleService(
Settings.EMPTY,
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e)),
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e), new NoOpClient(threadPool)),
clusterService,
clock
)
Expand Down Expand Up @@ -329,7 +331,7 @@ public void testPolicyNamesEndingInNumbers() throws Exception {
ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
SnapshotLifecycleService sls = new SnapshotLifecycleService(
Settings.EMPTY,
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e)),
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e), new NoOpClient(threadPool)),
clusterService,
clock
)
Expand Down Expand Up @@ -509,7 +511,7 @@ public void submitUnbatchedStateUpdateTask(String source, ClusterStateUpdateTask

SnapshotLifecycleService service = new SnapshotLifecycleService(
Settings.EMPTY,
(projectId) -> new SnapshotLifecycleTask(projectId, null, null, null),
(projectId) -> new SnapshotLifecycleTask(projectId, new NoOpClient(threadPool), null, null),
fakeService,
clock
);
Expand All @@ -529,8 +531,8 @@ public void submitUnbatchedStateUpdateTask(String source, ClusterStateUpdateTask
class FakeSnapshotTask extends SnapshotLifecycleTask {
private final Consumer<SchedulerEngine.Event> onTriggered;

FakeSnapshotTask(Consumer<SchedulerEngine.Event> onTriggered) {
super(projectId, null, null, null);
FakeSnapshotTask(Consumer<SchedulerEngine.Event> onTriggered, Client client) {
super(projectId, client, null, null);
this.onTriggered = onTriggered;
}

Expand Down