Skip to content

Conversation

@wntmddus
Copy link
Contributor

@wntmddus wntmddus commented Nov 5, 2025

Description

This PR adds three new configuration options to the convert_index_to_remote action, providing more flexibility and control during remote snapshot restore operations:

  1. include_aliases (boolean, default: false): Controls whether index aliases should be included during the restore operation.
  2. ignore_index_settings (string, default: empty): Comma-separated list of index settings to ignore during restore (e.g., "index.refresh_interval,index.number_of_replicas").
  3. number_of_replicas (integer, default: 0): Sets the number of replicas for the restored remote index.

Problem Statement:

For number_of_replicas:
When converting an index to a remote snapshot (Searchable Snapshot), users currently need to set the number of replicas either before the snapshot action or after the convert_index_to_remote action completes. Both approaches have drawbacks:

  • Setting replicas before conversion loses redundancy during the snapshot process
  • Setting replicas after conversion can lead to unnecessary load or yellow cluster state if there aren't enough eligible nodes for replica restoration

For include_aliases and ignore_index_settings:
Previously, the convert_index_to_remote action lacked the ability to control alias inclusion and index settings during restore, limiting users' ability to fine-tune the restore behavior to match their specific requirements. These options are available in the manual restore API but were not exposed through the ISM action.

For original index deletion:
The action now automatically deletes the original index after the remote snapshot restore is successfully accepted. This ensures that only the remote index remains, completing the conversion process and avoiding duplicate indices.

Solution:
This change adds three new fields to the convert_index_to_remote action, aligning it with the manual restore API capabilities:

  • include_aliases: Maps to RestoreSnapshotRequest.includeAliases()
  • ignore_index_settings: Maps to RestoreSnapshotRequest.ignoreIndexSettings()
  • number_of_replicas: Applied via RestoreSnapshotRequest.indexSettings() with SETTING_NUMBER_OF_REPLICAS

Additionally, the action automatically deletes the original index once the restore operation is accepted (status: ACCEPTED or OK), ensuring a clean conversion process where only the remote index remains.

Implementation Details:

  • Added includeAliases: Boolean = false parameter to ConvertIndexToRemoteAction class
  • Added ignoreIndexSettings: String = "" parameter to ConvertIndexToRemoteAction class
  • Added numberOfReplicas: Int = 0 parameter to ConvertIndexToRemoteAction class
  • Updated ConvertIndexToRemoteActionParser to parse all three fields from XContent and StreamInput
  • Modified AttemptRestoreStep to apply all three settings in the RestoreSnapshotRequest:
    • includeAliases() method for alias inclusion
    • ignoreIndexSettings() method for ignored settings
    • indexSettings() method with SETTING_NUMBER_OF_REPLICAS for replica count
  • Added automatic deletion of the original index after the restore operation is successfully accepted, ensuring a clean conversion process
  • Updated mapping files to include:
    • include_aliases (type: boolean)
    • ignore_index_settings (type: keyword)
    • number_of_replicas (type: integer)
  • Added comprehensive unit tests and updated existing tests to cover all new functionality

Example Usage:

{
  "convert_index_to_remote": {
    "repository": "backup-repo",
    "snapshot": "daily-snapshot",
    "include_aliases": true,
    "ignore_index_settings": "index.refresh_interval,index.number_of_replicas",
    "number_of_replicas": 0
  }
}

Related Issues

Resolves #1487, #808 (comment)

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…ings to convert_index_to_remote action in ISM

Signed-off-by: Seung Yeon Joo <[email protected]>
Seung Yeon Joo added 2 commits November 4, 2025 19:20
Signed-off-by: Seung Yeon Joo <[email protected]>
Signed-off-by: Seung Yeon Joo <[email protected]>
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 76.31579% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.25%. Comparing base (a8e15da) to head (2d24137).

Files with missing lines Patch % Lines
...statemanagement/step/restore/AttemptRestoreStep.kt 66.66% 14 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1527      +/-   ##
==========================================
+ Coverage   76.11%   76.25%   +0.13%     
==========================================
  Files         375      375              
  Lines       17565    17622      +57     
  Branches     2409     2412       +3     
==========================================
+ Hits        13370    13437      +67     
+ Misses       2958     2939      -19     
- Partials     1237     1246       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Seung Yeon Joo <[email protected]>
Comment on lines +55 to +57
out.writeBoolean(includeAliases)
out.writeString(ignoreIndexSettings)
out.writeInt(numberOfReplicas)
Copy link
Member

Choose a reason for hiding this comment

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

We need a version check here to maintain BWC during rolling upgrades.

Comment on lines +24 to +26
val includeAliases = sin.readBoolean()
val ignoreIndexSettings = sin.readString()
val numberOfReplicas = sin.readInt()
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, we need a version check here to maintain BWC during rolling upgrades.


when (response.status()) {
RestStatus.ACCEPTED, RestStatus.OK -> {
deleteOriginalIndex(context, indexName, mutableInfo)
Copy link
Member

Choose a reason for hiding this comment

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

Since the snapshot restore is not waiting for completion, I worry delete index here would disrupt the search.

I see you mentioned this:

the action automatically deletes the original index once the restore operation is accepted (status: ACCEPTED or OK), ensuring a clean conversion process where only the remote index remains.

But I think we should keep this an option for user, and disabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Setting number of replicas in "convert_index_to_remote" or "snapshot" action directly

3 participants