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
6 changes: 6 additions & 0 deletions docs/changelog/102934.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 102934
summary: Ensure transform updates only modify the expected transform task
area: Transform
type: bug
issues:
- 102933
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser;
Expand Down Expand Up @@ -186,6 +187,15 @@ public boolean equals(Object obj) {
&& Objects.equals(authState, other.authState)
&& getTimeout().equals(other.getTimeout());
}

@Override
public boolean match(Task task) {
if (task.getDescription().startsWith(TransformField.PERSISTENT_TASK_DESCRIPTION_PREFIX)) {
String taskId = task.getDescription().substring(TransformField.PERSISTENT_TASK_DESCRIPTION_PREFIX.length());
return taskId.equals(this.id);
}
return false;
}
}

public static class Response extends BaseTasksResponse implements ToXContentObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.persistent.AllocatedPersistentTask;
import org.elasticsearch.xpack.core.transform.action.UpdateTransformAction.Request;
import org.elasticsearch.xpack.core.transform.transforms.AuthorizationStateTests;
import org.elasticsearch.xpack.core.transform.transforms.TransformConfigTests;
Expand Down Expand Up @@ -74,4 +75,12 @@ protected Request mutateInstance(Request instance) {

return new Request(update, id, deferValidation, timeout);
}

public void testMatch() {
Request request = new Request(randomTransformConfigUpdate(), "my-transform-7", false, null);
assertTrue(request.match(new AllocatedPersistentTask(123, "", "", "data_frame_my-transform-7", null, null)));
assertFalse(request.match(new AllocatedPersistentTask(123, "", "", "data_frame_my-transform-", null, null)));
assertFalse(request.match(new AllocatedPersistentTask(123, "", "", "data_frame_my-transform-77", null, null)));
assertFalse(request.match(new AllocatedPersistentTask(123, "", "", "my-transform-7", null, null)));
}
}