Skip to content

Commit 76013fa

Browse files
authored
[Transform] Ensure transform updates only modify the expected transform task (#102934) (#102940)
1 parent 637baa9 commit 76013fa

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

docs/changelog/102934.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 102934
2+
summary: Ensure transform updates only modify the expected transform task
3+
area: Transform
4+
type: bug
5+
issues:
6+
- 102933

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/UpdateTransformAction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.common.io.stream.StreamInput;
1616
import org.elasticsearch.common.io.stream.StreamOutput;
1717
import org.elasticsearch.core.TimeValue;
18+
import org.elasticsearch.tasks.Task;
1819
import org.elasticsearch.xcontent.ToXContentObject;
1920
import org.elasticsearch.xcontent.XContentBuilder;
2021
import org.elasticsearch.xcontent.XContentParser;
@@ -187,6 +188,15 @@ public boolean equals(Object obj) {
187188
&& Objects.equals(authState, other.authState)
188189
&& getTimeout().equals(other.getTimeout());
189190
}
191+
192+
@Override
193+
public boolean match(Task task) {
194+
if (task.getDescription().startsWith(TransformField.PERSISTENT_TASK_DESCRIPTION_PREFIX)) {
195+
String taskId = task.getDescription().substring(TransformField.PERSISTENT_TASK_DESCRIPTION_PREFIX.length());
196+
return taskId.equals(this.id);
197+
}
198+
return false;
199+
}
190200
}
191201

192202
public static class Response extends BaseTasksResponse implements ToXContentObject {

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/action/UpdateTransformActionRequestTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.elasticsearch.common.io.stream.Writeable;
1111
import org.elasticsearch.core.TimeValue;
12+
import org.elasticsearch.persistent.AllocatedPersistentTask;
1213
import org.elasticsearch.xpack.core.transform.action.UpdateTransformAction.Request;
1314
import org.elasticsearch.xpack.core.transform.transforms.AuthorizationStateTests;
1415
import org.elasticsearch.xpack.core.transform.transforms.TransformConfigTests;
@@ -74,4 +75,12 @@ protected Request mutateInstance(Request instance) {
7475

7576
return new Request(update, id, deferValidation, timeout);
7677
}
78+
79+
public void testMatch() {
80+
Request request = new Request(randomTransformConfigUpdate(), "my-transform-7", false, null);
81+
assertTrue(request.match(new AllocatedPersistentTask(123, "", "", "data_frame_my-transform-7", null, null)));
82+
assertFalse(request.match(new AllocatedPersistentTask(123, "", "", "data_frame_my-transform-", null, null)));
83+
assertFalse(request.match(new AllocatedPersistentTask(123, "", "", "data_frame_my-transform-77", null, null)));
84+
assertFalse(request.match(new AllocatedPersistentTask(123, "", "", "my-transform-7", null, null)));
85+
}
7786
}

0 commit comments

Comments
 (0)