Skip to content

[BUG] Update index.knn setting to be immutable on restore snapshot #17019

Open
@anntians

Description

Describe the bug

This issue builds on top of this KNN issue: opensearch-project/k-NN#2334. Today, user can update index.knn flag even after an index is created which should not be allowed. For instance, users can close an index, update index.knn, and reopen index. This bug has be resolved by this PR: opensearch-project/k-NN#2348. However, another loophole is users can take a snapshot of an index, delete index, and update index.knn on restore from snapshot.

The focus of this issue is for the bug case when restoring from snapshot. There is an open PR: #16957 attempting to fix the bug, but there are a few implementation considerations that need to be discussed. The current implementation in the PR is not best practice as it introduces plugin-specific settings in core Opensearch. So below are two suggestions on implementation:

  1. Expand functionality of RestoreInProgress class to include settings that are updated from the restore request

Currently in execute of restoreService we store a custom object RestoreInProgress in the clusterState here. We could update RestoreInProgress to include a diff of index settings changed, so that once the clusterState is passed downstream to the IndexEventListener callback methods, we can perform validation checks from within the KNN plugin.

Pro: Perform validation within KNN plugin. Straightforward to expand on an existing custom class that is part of clusterState. Faster implementation/merge timeline.

Con: Doesn't offer great extensibility if in the future we want to add more use cases to access data/updates during restore operations.

  1. Add a new callback method beforeIndexRestore() to IndexEventListener and trigger it within restoreService.

Currently, the reason we cannot use the existing callback methods in IndexEventListener is because they do not have access to the prev clusterState to know which settings were updated. Further the callback methods can be triggered from other non-restore API calls. However, if we create a new callback method that will strictly be called in the restoreService, pass it clusterState and diff of changed settings, then we can perform validation from within the KNN plugin.

Pro: Creates better extensibility for other use cases to build off of this new callback method in the future. There have been several requests for additional access for restore related updates

Con: Will have to go through several approvals and discussions to make this change, as it updates the core repository and affects future customers/contributors use cases. Will be a longer completion date compared to option 1.

I would like to start a discussion on which option to execute on and additional context that may help resolve this bug.

Related component

Storage:Snapshots

To Reproduce

  1. Register Snapshot directory
  2. Create Index
  3. Take Snapshot of Index
  4. Delete Index
  5. Restore Snapshot of index with index.knn setting updated. Will restore index with the updated setting

Expected behavior

index.knn should be immutable on restore. An error should be thrown if the setting is updated on restore api call

Additional Details

Additional context
Original issue: opensearch-project/k-NN#2334
PR for original issue: opensearch-project/k-NN#2348
Open PR for this issue: #16957

Metadata

Assignees

Labels

Type

No type

Projects

  • Status

    🆕 New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions