-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Require project-id for waitForPersistentTasksCondition #124180
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,12 +19,14 @@ | |
| import org.elasticsearch.action.support.tasks.TransportTasksAction; | ||
| import org.elasticsearch.client.internal.Client; | ||
| import org.elasticsearch.cluster.ClusterState; | ||
| import org.elasticsearch.cluster.metadata.Metadata; | ||
| import org.elasticsearch.cluster.node.DiscoveryNodes; | ||
| import org.elasticsearch.cluster.service.ClusterService; | ||
| import org.elasticsearch.common.util.concurrent.AbstractRunnable; | ||
| import org.elasticsearch.common.util.concurrent.AtomicArray; | ||
| import org.elasticsearch.common.util.concurrent.ConcurrentCollections; | ||
| import org.elasticsearch.common.util.concurrent.EsExecutors; | ||
| import org.elasticsearch.core.FixForMultiProject; | ||
| import org.elasticsearch.core.TimeValue; | ||
| import org.elasticsearch.discovery.MasterNotDiscoveredException; | ||
| import org.elasticsearch.injection.guice.Inject; | ||
|
|
@@ -642,7 +644,12 @@ void waitForJobClosed( | |
| ActionListener<CloseJobAction.Response> listener, | ||
| Set<String> movedJobs | ||
| ) { | ||
| persistentTasksService.waitForPersistentTasksCondition(persistentTasksCustomMetadata -> { | ||
| @FixForMultiProject | ||
| final var projectId = Metadata.DEFAULT_PROJECT_ID; | ||
| persistentTasksService.waitForPersistentTasksCondition(projectId, persistentTasksCustomMetadata -> { | ||
| if (persistentTasksCustomMetadata == null) { | ||
| return true; | ||
| } | ||
|
Comment on lines
+650
to
+652
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added similar null check in most of the call sites. It looks correct to me since all usages are either waiting for all tasks to be removed or not on certain state. Additionally, the same null check is already in place for TransportStopTransformAction. I think it's likely a noop for single project setup since the method is called only after the tasks have started. Having it feels more future proof for multi-project where project might be concurrently removed. It might be that the project deletion is orderly so that a project won't be removed until all tasks have cleared out. In that case, this check will be a noop. Overall I feel it is safer to have it in any case. |
||
| for (PersistentTasksCustomMetadata.PersistentTask<?> originalPersistentTask : waitForCloseRequest.persistentTasks) { | ||
| String originalPersistentTaskId = originalPersistentTask.getId(); | ||
| PersistentTasksCustomMetadata.PersistentTask<?> currentPersistentTask = persistentTasksCustomMetadata.getTask( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you didn't also update the (overloaded)
waitForPersistentTasksConditionmethod above? I think it makes sense to do both within this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other method is not an overload, it is
waitForPersistentTaskCondition, note the singularTask. I didn't touch that because you handled it in #124000?