Skip to content

Adding new reindex data stream apis #3518

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
merged 7 commits into from
Jan 17, 2025
Merged

Adding new reindex data stream apis #3518

merged 7 commits into from
Jan 17, 2025

Conversation

pquentin
Copy link
Member

This is a trick to run validation on #3517.

This adds elasticsearch-specification code for the new data stream reindex API. Specifically:

  • /_migration/reindex
  • /_migration/reindex/{index}/_status
  • /_migration/reindex/{index}/_cancel
  • /_create_from/{source}/{dest}

@pquentin pquentin requested a review from a team as a code owner January 15, 2025 05:50
Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
migrate.cancel_reindex Missing test Missing test
migrate.create_from 🟠 Missing recording Missing recording
migrate.get_reindex_status Missing test Missing test
migrate.reindex 🟠 Missing recording Missing recording

You can validate these APIs yourself by using the make validate target.

Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
migrate.cancel_reindex Missing test Missing test
migrate.create_from 🟠 Missing recording Missing recording
migrate.get_reindex_status Missing test Missing test
migrate.reindex 🟠 Missing recording Missing recording

You can validate these APIs yourself by using the make validate target.

Copy link
Member Author

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks! I was able to run our YAML test validation locally, and fixed the relevant issues. I also ran make contrib to make validation run, even though it's not super useful for now.

(Also, oops, I'm just realizing that I commented my own PR. Feel free to add your fixes there.)

*/

import { RequestBase } from '@_types/Base'
import { CreateFrom } from '../_types/CreateFrom'
Copy link
Member Author

Choose a reason for hiding this comment

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

Since CreateFrom is only used in this file, it can be included inline. As mentioned in https://github.com/elastic/elasticsearch-specification/blob/main/docs/add-new-api.md:

Try to use less files as possible, for example there is no need to create a custom file for an enum, you can define it in the same file where it's used, unless is a commonly used type.

Comment on lines 34 to 37
/** The source index or data stream name */
source: string
/** The destination index or data stream name */
dest: string
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
/** The source index or data stream name */
source: string
/** The destination index or data stream name */
dest: string
/** The source index or data stream name */
source: IndexName
/** The destination index or data stream name */
dest: IndexName

(You will also need to add import { IndexName } from '@_types/common' at the top of the file.)

Comment on lines +22 to +28
export class Response {
body: {
acknowledged: boolean
index: IndexName
shards_acknowledged: boolean
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm wondering, how/why isn't toXContent used? I know it's not a mistake, as it's confirmed by the YAML tests.

Copy link
Member

Choose a reason for hiding this comment

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

Ha, we knew that question would come up, which is why it's in that comment:

        /*
         * This only exists for the sake of testing the xcontent parser
         */

This is the request, not the response. The response is just AcknowledgedResponse. The request accepts xcontent. In order to use AbstractXContentSerializingTestCase, we added this toXContent (although for unrelated reasons we later ripped that out and wrote our own xcontent serialization test, and could have moved this toXContent into the unit test).

import { AcknowledgedResponseBase } from '@_types/Base'

export class Response {
body: AcknowledgedResponseBase
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm also confused, why isn't toXContent used?

Copy link
Member

Choose a reason for hiding this comment

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

This is a bug in my PR. I'll fix it.

*/

import { RequestBase } from '@_types/Base'
import { MigrateReindex } from '../_types/MigrateReindex'
Copy link
Member Author

Choose a reason for hiding this comment

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

As above, since MigrateReindex is only used in this file, it can be included inline.

/**
* Reindex mode. Currently only 'upgrade' is supported.
*/
mode: string
Copy link
Member Author

Choose a reason for hiding this comment

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

source: Index
}

export class Index {
Copy link
Member Author

Choose a reason for hiding this comment

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

Please use a more specific name, maybe SourceIndex?

import { AcknowledgedResponseBase } from '@_types/Base'

export class Response {
body: AcknowledgedResponseBase
Copy link
Member Author

Choose a reason for hiding this comment

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

Again, toXContent does not appear to be used. (And this is confirmed by the YAML tests.)

Copy link
Member

Choose a reason for hiding this comment

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

This is for historical reasons. The Response originally returned information, but was changed to return nothing other than what AcknowledgeResponse returns. I'll fix that in Elasticsearch.
The request implements toXContent, but that's for serialization testing in the unit test only.

Copy link
Member

Choose a reason for hiding this comment

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

Removed in elastic/elasticsearch#120321. I think this PR is correct as-is though (for this).

Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
migrate.cancel_reindex Missing test Missing test
migrate.create_from 🟠 Missing recording Missing recording
migrate.get_reindex_status Missing test Missing test
migrate.reindex 🟠 Missing recording Missing recording

You can validate these APIs yourself by using the make validate target.

Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
migrate.cancel_reindex Missing test Missing test
migrate.create_from 🟠 Missing recording Missing recording
migrate.get_reindex_status Missing test Missing test
migrate.reindex 🟠 Missing recording Missing recording

You can validate these APIs yourself by using the make validate target.

Copy link
Member Author

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM! Validation passed locally:

❯ make validate api=migrate.create_from branch=main
Validating endpoints
Validating migrate.create_from
migrate.create_from request has been successfully validated!

✔ 2 out of 2 test request cases are passing.
✔ 2 out of 2 test response cases are passing.

❯ make validate api=migrate.reindex branch=main
Validating endpoints
Validating migrate.reindex
migrate.reindex request has been successfully validated!

✔ 2 out of 2 test request cases are passing.
✔ 2 out of 2 test response cases are passing.

❯ make validate api=migrate.get_reindex_status branch=main
Validating endpoints
Validating migrate.get_reindex_status
migrate.get_reindex_status request has been successfully validated!

✔ 1 out of 1 test request cases are passing.
✔ 1 out of 1 test response cases are passing.

@pquentin
Copy link
Member Author

I can't approve my PR. Can you please do it and merge it? Thank you.

@masseyke masseyke merged commit b596a79 into main Jan 17, 2025
8 checks passed
@masseyke masseyke deleted the reindex-apis branch January 17, 2025 14:11
github-actions bot pushed a commit that referenced this pull request Jan 17, 2025
Co-authored-by: Keith Massey <[email protected]>
(cherry picked from commit b596a79)
pquentin added a commit that referenced this pull request Jan 21, 2025
pquentin added a commit that referenced this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants