Skip to content

Reindex service - rename rest api url paths#233532

Merged
mattkime merged 12 commits intolookup_reindex_servicefrom
lookup_reindex_service_reindex_url_path
Sep 4, 2025
Merged

Reindex service - rename rest api url paths#233532
mattkime merged 12 commits intolookup_reindex_servicefrom
lookup_reindex_service_reindex_url_path

Conversation

@mattkime
Copy link
Contributor

@mattkime mattkime commented Aug 29, 2025

Summary

/api/upgrade_assistant => /api/reindex_service where appropriate

So the url matches the api name. A cleanup step after a lot of refactoring

@mattkime mattkime changed the title change rest api url path Reindex service - rename rest api url paths Sep 3, 2025
@mattkime mattkime self-assigned this Sep 3, 2025
@mattkime mattkime added Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// Feature:Upgrade Assistant backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Sep 3, 2025
@mattkime mattkime requested a review from sabarasaba September 3, 2025 22:34
@mattkime mattkime marked this pull request as ready for review September 4, 2025 00:14
@mattkime mattkime requested a review from a team as a code owner September 4, 2025 00:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@elastic elastic deleted a comment from elasticmachine Sep 4, 2025
@mattkime
Copy link
Contributor Author

mattkime commented Sep 4, 2025

/ci

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
reindexService 53 55 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
reindexService 3.2KB 3.3KB +96.0B
Unknown metric groups

API count

id before after diff
reindexService 60 62 +2

History

cc @mattkime

Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

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

killer! changes lgtm

@mattkime mattkime merged commit de120bf into lookup_reindex_service Sep 4, 2025
12 checks passed
@mattkime mattkime deleted the lookup_reindex_service_reindex_url_path branch September 4, 2025 10:10
mattkime added a commit that referenced this pull request Sep 4, 2025
… apis (#230475)

Note - #233532 builds on top of
this PR and its the PR you want to run to test the code. The PRs were
kept separate for clarity.

---

Previously it was assumed that if you were reindexing it could only be
in the service of upgrading. Now Upgrade Assistant is responsible for
using the reindexing service for upgrading and the reindexing service is
agnostic of any upgrade concerns.

This PR does the following -
1) Reindexing APIs need to be told the name of the new index (previously
it was calculated)
2) Creates a ReindexServerWrapper which aims to be a simplified API.
Previously there were a couple of different classes/functions which in
combination created a CRUD api but this wraps them all together to
provide a simpler API. The dependencies are passed to instantiate the
API and then the useful apis are returned. There are separate internal
and external apis, internal mainly pertains to lifecycle and general
housekeeping while external api is for CRUD operations.
3) Supports passing the type of index to be created
4) Removal of old index is optional, if its removed an alias points from
old to new index.

```
ReindexService.reindex({
     indexName: 'kibanaIndex',
     newIndexName: 'kibanaIndexReindexed',
     settings: { mode: 'lookup' },
     reindexOptions: { deleteOldIndex: true },
});
```

```
POST kbn:/api/upgrade_assistant/reindex
{
    "indexName" : "kibana_sample_data_flights",
    "newIndexName" : "ksdf",
    "settings": {
        "mode": "lookup"
    },
    "reindexOptions": {
         "deleteOldIndex": false, // defaults to false
    }
}
```

To test upgrade assistant, follow directions here -
#228705
Mock data here -
https://github.com/elastic/kibana/pull/230021/files#diff-f7eb2d7fe666aad1bedcd73d356612d2f74f81c76ba2e8e26b2983b9fb92a661R49

Follow ups - 
- This PR removes rest api integration tests that were previously
disabled. We should consider how we might implement these.
- `cleanupReindexOperations` is called when the user visits the Upgrade
Assistant page. This doesn't really have a place in the general purpose
reindexing service. Ideally the reindex job saved objects would simply
be removed when the task is complete but this would require a close
examination of the reindex saved object lifecycle which is outside the
scope of this PR.
- Address Upgrade Assistant flyout missing new index name 
- Ideally the reindexing service would be completely agnostic of version
concerns but deep within the reindexing code it looks at which index
settings should be removed when migrating to version 8. This should be
an Upgrade Assistant concern BUT this change is outside of the scope of
this PR.

<img width="508" height="820" alt="Screenshot 2025-09-03 at 12 21 21 AM"
src="https://github.com/user-attachments/assets/ed478a13-b1ac-4d0f-826e-5ebf5b9641c0"
/>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Ignacio Rivas <rivasign@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Cesare de Cal <cesare.decal@elastic.co>
ymao1 pushed a commit to ymao1/kibana that referenced this pull request Sep 4, 2025
… apis (elastic#230475)

Note - elastic#233532 builds on top of
this PR and its the PR you want to run to test the code. The PRs were
kept separate for clarity.

---

Previously it was assumed that if you were reindexing it could only be
in the service of upgrading. Now Upgrade Assistant is responsible for
using the reindexing service for upgrading and the reindexing service is
agnostic of any upgrade concerns.

This PR does the following -
1) Reindexing APIs need to be told the name of the new index (previously
it was calculated)
2) Creates a ReindexServerWrapper which aims to be a simplified API.
Previously there were a couple of different classes/functions which in
combination created a CRUD api but this wraps them all together to
provide a simpler API. The dependencies are passed to instantiate the
API and then the useful apis are returned. There are separate internal
and external apis, internal mainly pertains to lifecycle and general
housekeeping while external api is for CRUD operations.
3) Supports passing the type of index to be created
4) Removal of old index is optional, if its removed an alias points from
old to new index.

```
ReindexService.reindex({
     indexName: 'kibanaIndex',
     newIndexName: 'kibanaIndexReindexed',
     settings: { mode: 'lookup' },
     reindexOptions: { deleteOldIndex: true },
});
```

```
POST kbn:/api/upgrade_assistant/reindex
{
    "indexName" : "kibana_sample_data_flights",
    "newIndexName" : "ksdf",
    "settings": {
        "mode": "lookup"
    },
    "reindexOptions": {
         "deleteOldIndex": false, // defaults to false
    }
}
```

To test upgrade assistant, follow directions here -
elastic#228705
Mock data here -
https://github.com/elastic/kibana/pull/230021/files#diff-f7eb2d7fe666aad1bedcd73d356612d2f74f81c76ba2e8e26b2983b9fb92a661R49

Follow ups - 
- This PR removes rest api integration tests that were previously
disabled. We should consider how we might implement these.
- `cleanupReindexOperations` is called when the user visits the Upgrade
Assistant page. This doesn't really have a place in the general purpose
reindexing service. Ideally the reindex job saved objects would simply
be removed when the task is complete but this would require a close
examination of the reindex saved object lifecycle which is outside the
scope of this PR.
- Address Upgrade Assistant flyout missing new index name 
- Ideally the reindexing service would be completely agnostic of version
concerns but deep within the reindexing code it looks at which index
settings should be removed when migrating to version 8. This should be
an Upgrade Assistant concern BUT this change is outside of the scope of
this PR.

<img width="508" height="820" alt="Screenshot 2025-09-03 at 12 21 21 AM"
src="https://github.com/user-attachments/assets/ed478a13-b1ac-4d0f-826e-5ebf5b9641c0"
/>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Ignacio Rivas <rivasign@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Cesare de Cal <cesare.decal@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Upgrade Assistant release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants