Skip to content

Commit de92d49

Browse files
authored
Add origin to client in SLM task (#135484)
1 parent acd4068 commit de92d49

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

docs/changelog/135484.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135484
2+
summary: Add origin to client in SLM task
3+
area: ILM+SLM
4+
type: bug
5+
issues: []

x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycleTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
1717
import org.elasticsearch.action.admin.cluster.snapshots.get.TransportGetSnapshotsAction;
1818
import org.elasticsearch.client.internal.Client;
19+
import org.elasticsearch.client.internal.OriginSettingClient;
1920
import org.elasticsearch.cluster.ClusterState;
2021
import org.elasticsearch.cluster.ClusterStateUpdateTask;
2122
import org.elasticsearch.cluster.ProjectState;
@@ -79,7 +80,7 @@ public SnapshotLifecycleTask(
7980
final SnapshotHistoryStore historyStore
8081
) {
8182
this.projectId = projectId;
82-
this.client = client;
83+
this.client = new OriginSettingClient(client, ClientHelper.INDEX_LIFECYCLE_ORIGIN);
8384
this.clusterService = clusterService;
8485
this.historyStore = historyStore;
8586
}

x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleServiceTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.elasticsearch.xpack.slm;
99

1010
import org.apache.lucene.util.SetOnce;
11+
import org.elasticsearch.client.internal.Client;
1112
import org.elasticsearch.cluster.ClusterChangedEvent;
1213
import org.elasticsearch.cluster.ClusterName;
1314
import org.elasticsearch.cluster.ClusterState;
@@ -31,6 +32,7 @@
3132
import org.elasticsearch.core.TimeValue;
3233
import org.elasticsearch.test.ClusterServiceUtils;
3334
import org.elasticsearch.test.ESTestCase;
35+
import org.elasticsearch.test.client.NoOpClient;
3436
import org.elasticsearch.threadpool.TestThreadPool;
3537
import org.elasticsearch.threadpool.ThreadPool;
3638
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
@@ -129,7 +131,7 @@ public void testNothingScheduledWhenNotRunning() throws InterruptedException {
129131
ClusterService clusterService = ClusterServiceUtils.createClusterService(initialState, threadPool);
130132
SnapshotLifecycleService sls = new SnapshotLifecycleService(
131133
Settings.EMPTY,
132-
(projectId) -> new FakeSnapshotTask(e -> logger.info("triggered")),
134+
(projectId) -> new FakeSnapshotTask(e -> logger.info("triggered"), new NoOpClient(threadPool)),
133135
clusterService,
134136
clock
135137
)
@@ -198,7 +200,7 @@ public void testPolicyCRUD() throws Exception {
198200
ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
199201
SnapshotLifecycleService sls = new SnapshotLifecycleService(
200202
Settings.EMPTY,
201-
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e)),
203+
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e), new NoOpClient(threadPool)),
202204
clusterService,
203205
clock
204206
)
@@ -329,7 +331,7 @@ public void testPolicyNamesEndingInNumbers() throws Exception {
329331
ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
330332
SnapshotLifecycleService sls = new SnapshotLifecycleService(
331333
Settings.EMPTY,
332-
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e)),
334+
(projectId) -> new FakeSnapshotTask(e -> trigger.get().accept(e), new NoOpClient(threadPool)),
333335
clusterService,
334336
clock
335337
)
@@ -509,7 +511,7 @@ public void submitUnbatchedStateUpdateTask(String source, ClusterStateUpdateTask
509511

510512
SnapshotLifecycleService service = new SnapshotLifecycleService(
511513
Settings.EMPTY,
512-
(projectId) -> new SnapshotLifecycleTask(projectId, null, null, null),
514+
(projectId) -> new SnapshotLifecycleTask(projectId, new NoOpClient(threadPool), null, null),
513515
fakeService,
514516
clock
515517
);
@@ -529,8 +531,8 @@ public void submitUnbatchedStateUpdateTask(String source, ClusterStateUpdateTask
529531
class FakeSnapshotTask extends SnapshotLifecycleTask {
530532
private final Consumer<SchedulerEngine.Event> onTriggered;
531533

532-
FakeSnapshotTask(Consumer<SchedulerEngine.Event> onTriggered) {
533-
super(projectId, null, null, null);
534+
FakeSnapshotTask(Consumer<SchedulerEngine.Event> onTriggered, Client client) {
535+
super(projectId, client, null, null);
534536
this.onTriggered = onTriggered;
535537
}
536538

0 commit comments

Comments
 (0)