Skip to content

Adding a migration reindex cancel API #118291

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

Merged

Conversation

masseyke
Copy link
Member

@masseyke masseyke commented Dec 9, 2024

This introduces the migration reindex cancel API, which cancels a migration reindex task for a given data stream name that was started with #118109. For example:

POST localhost:9200/_migration/reindex/my-data-stream/_cancel?pretty

returns

{
  "acknowledged" : true
}

This cancels the task, and cancels any ongoing reindexing of backing indices, but does not do any cleanup.

@masseyke masseyke added >enhancement :Data Management/Data streams Data streams and their lifecycles auto-backport Automatically create backport pull requests when merged v9.0.0 v8.18.0 labels Dec 9, 2024
@elasticsearchmachine
Copy link
Collaborator

Hi @masseyke, I've created a changelog YAML for you.

@masseyke masseyke marked this pull request as ready for review December 10, 2024 22:35
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Dec 10, 2024
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("acknowledged", true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this action just use AcknowledgeResponse directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, it could! In an early iteration I was returning the latest status information so the response had fields in it. But then I decided that was unnecessary and forgot to remove the response class.

)
);
} else {
runningTask.markAsCompleted();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this all that's needed to cancel the actual reindex code? Or does there need to be cancel specific logic built into the per-index reindexing code, which will be called here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like markAsCompleed is the wrong way to go. I'm going to change this to use PersistentTasksService::sendRemoveRequest instead. And we just need to make sure the parent task is set on all of our transport actions to have the cancellation propagate.

Copy link
Contributor

@parkertimmins parkertimmins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

* the task manager). The running task is removed from the task manager in ReindexDataStreamTask::onCancelled, which is called as
* as result of this.
*/
persistentTasksService.sendRemoveRequest(persistentTaskId, TimeValue.MAX_VALUE, new ActionListener<>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, could do:
listener.delegateResponse((l, e) -> l.onResponse(AcknowledgedResponse.TRUE))

@masseyke masseyke added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Dec 12, 2024
@elasticsearchmachine elasticsearchmachine merged commit 9b095eb into elastic:main Dec 12, 2024
16 checks passed
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Dec 13, 2024
This introduces the migration reindex cancel API, which cancels a
migration reindex task for a given data stream name that was started
with elastic#118109. For example:

```
POST localhost:9200/_migration/reindex/my-data-stream/_cancel?pretty
```

returns

```
{
  "acknowledged" : true
}
```

This cancels the task, and cancels any ongoing reindexing of backing
indices, but does not do any cleanup.
@masseyke masseyke deleted the adding-migration-reindex-cancel-api branch December 13, 2024 15:20
elasticsearchmachine pushed a commit that referenced this pull request Dec 13, 2024
This introduces the migration reindex cancel API, which cancels a
migration reindex task for a given data stream name that was started
with #118109. For example:

```
POST localhost:9200/_migration/reindex/my-data-stream/_cancel?pretty
```

returns

```
{
  "acknowledged" : true
}
```

This cancels the task, and cancels any ongoing reindexing of backing
indices, but does not do any cleanup.
maxhniebergall pushed a commit to maxhniebergall/elasticsearch that referenced this pull request Dec 16, 2024
This introduces the migration reindex cancel API, which cancels a
migration reindex task for a given data stream name that was started
with elastic#118109. For example:

```
POST localhost:9200/_migration/reindex/my-data-stream/_cancel?pretty
```

returns

```
{
  "acknowledged" : true
}
```

This cancels the task, and cancels any ongoing reindexing of backing
indices, but does not do any cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Data Management/Data streams Data streams and their lifecycles >enhancement Team:Data Management Meta label for data/management team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants