-
Notifications
You must be signed in to change notification settings - Fork 141
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
Add UnmodifiableOnRestore property to index.knn setting #2445
Add UnmodifiableOnRestore property to index.knn setting #2445
Conversation
Signed-off-by: AnnTian Shao <[email protected]>
Signed-off-by: AnnTian Shao <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a changelog entry.
@kotwanikunal This PR is a followup/part of a larger change to make |
public void testUnmodifiableOnRestoreSettingModifiedOnRestore() throws Exception { | ||
setupSnapshotRestore(); | ||
|
||
// invalid restore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there are any existing helper methods in OpenSearchRestTestCase
/upstream classes for restore snapshot that take in setting updates and throws back validation errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me, just a minor comment to update the test name.
createSnapshot(repository, snapshot, true); | ||
} | ||
|
||
public void testUnmodifiableOnRestoreSettingModifiedOnRestore() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: May be we should rename this test as testKnnSettingIsUnmodifiableOnRestore
assertThat(error.getMessage(), containsString("cannot modify UnmodifiableOnRestore setting [index.knn]" + " on restore")); | ||
} | ||
|
||
public void testUnmodifiableOnRestoreSettingIgnoredOnRestore() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testKnnSettingCannotBeIgnoredDuringRestore
Signed-off-by: AnnTian Shao <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. Thanks!
createSnapshot(repository, snapshot, true); | ||
} | ||
|
||
public void testKnnSettingIsUnmodifiableOnRestore() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion]
The way we create test names in k-NN in testABC_whenXYZ_then(Success/Failure).
repository = "repo"; | ||
|
||
// create index | ||
Settings indexSettings = Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 1).put("index.knn", true).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that tests run on 1 single node, having a replica will keep the index yellow. Lets not have 1 replica.
I think lets use the index setting already present in the base classes
// create repo | ||
Settings repoSettings = Settings.builder().put("compress", randomBoolean()).put("location", pathRepo).build(); | ||
registerRepository(repository, "fs", true, repoSettings); | ||
|
||
// create snapshot | ||
createSnapshot(repository, snapshot, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets move this to base class since we can start using this function for other tests.
createSnapshot(repository, snapshot, true); | ||
} | ||
|
||
public void testKnnSettingIsUnmodifiableOnRestore() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use @SneakyThrows rather than exception in message signature
@anntians Please don't add the label skip-changelog and add correct entry in the changelog. |
} | ||
|
||
public void testKnnSettingIsUnmodifiableOnRestore() throws Exception { | ||
setupSnapshotRestore(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we are not using the @setup function here?
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.hasSize; | ||
|
||
public class RestoreSnapshotIT extends OpenSearchRestTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add a test for happy path. In both the tests I am seeing the unhappy path. :)
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.hasSize; | ||
|
||
public class RestoreSnapshotIT extends OpenSearchRestTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the base class KNNRestTestCase
which is there for all the IT of k-NN plugin
88b4beb
to
d5a4355
Compare
Signed-off-by: AnnTian Shao <[email protected]>
d5a4355
to
b722a00
Compare
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-main main
# Navigate to the new working tree
cd .worktrees/backport-main
# Create a new branch
git switch --create backport/backport-2445-to-main
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1d2c4c0c783428fdea7141ad069134a25b590c54
# Push it to GitHub
git push --set-upstream origin backport/backport-2445-to-main
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-main Then, create a pull request where the |
…roject#2445) * Add UnmodifiableOnRestore property to index.knn setting Signed-off-by: AnnTian Shao <[email protected]> * Update tests with helper methods Signed-off-by: AnnTian Shao <[email protected]> * Update test names Signed-off-by: AnnTian Shao <[email protected]> * Add to changeLog and fixes to tests Signed-off-by: AnnTian Shao <[email protected]> --------- Signed-off-by: AnnTian Shao <[email protected]> Co-authored-by: AnnTian Shao <[email protected]> (cherry picked from commit 1d2c4c0)
…roject#2445) * Add UnmodifiableOnRestore property to index.knn setting Signed-off-by: AnnTian Shao <[email protected]> * Update tests with helper methods Signed-off-by: AnnTian Shao <[email protected]> * Update test names Signed-off-by: AnnTian Shao <[email protected]> * Add to changeLog and fixes to tests Signed-off-by: AnnTian Shao <[email protected]> --------- Signed-off-by: AnnTian Shao <[email protected]> Co-authored-by: AnnTian Shao <[email protected]> (cherry picked from commit 1d2c4c0)
…roject#2445) * Add UnmodifiableOnRestore property to index.knn setting Signed-off-by: AnnTian Shao <[email protected]> * Update tests with helper methods Signed-off-by: AnnTian Shao <[email protected]> * Update test names Signed-off-by: AnnTian Shao <[email protected]> * Add to changeLog and fixes to tests Signed-off-by: AnnTian Shao <[email protected]> --------- Signed-off-by: AnnTian Shao <[email protected]> Co-authored-by: AnnTian Shao <[email protected]> (cherry picked from commit 1d2c4c0)
…roject#2445) * Add UnmodifiableOnRestore property to index.knn setting Signed-off-by: AnnTian Shao <[email protected]> * Update tests with helper methods Signed-off-by: AnnTian Shao <[email protected]> * Update test names Signed-off-by: AnnTian Shao <[email protected]> * Add to changeLog and fixes to tests Signed-off-by: AnnTian Shao <[email protected]> --------- Signed-off-by: AnnTian Shao <[email protected]> Co-authored-by: AnnTian Shao <[email protected]> (cherry picked from commit 1d2c4c0)
…roject#2445) * Add UnmodifiableOnRestore property to index.knn setting Signed-off-by: AnnTian Shao <[email protected]> * Update tests with helper methods Signed-off-by: AnnTian Shao <[email protected]> * Update test names Signed-off-by: AnnTian Shao <[email protected]> * Add to changeLog and fixes to tests Signed-off-by: AnnTian Shao <[email protected]> --------- Signed-off-by: AnnTian Shao <[email protected]> Co-authored-by: AnnTian Shao <[email protected]> (cherry picked from commit 1d2c4c0)
…roject#2445) * Add UnmodifiableOnRestore property to index.knn setting Signed-off-by: AnnTian Shao <[email protected]> * Update tests with helper methods Signed-off-by: AnnTian Shao <[email protected]> * Update test names Signed-off-by: AnnTian Shao <[email protected]> * Add to changeLog and fixes to tests Signed-off-by: AnnTian Shao <[email protected]> --------- Signed-off-by: AnnTian Shao <[email protected]> Co-authored-by: AnnTian Shao <[email protected]> (cherry picked from commit 1d2c4c0)
Description
This PR builds on another PR. In the other PR we added a new Setting property
UnmodifiableOnRestore
to prevent settings from being modified on restore. So in this PR we're adding that newUnmodifiableOnRestore
property to theindex.knn
setting to prevent it from being modified or removed on restore snapshot.Related Issues
Resolves Issue #2334
Also resolves Issue 17019 in Core Opensearch repository opensearch-project/OpenSearch#17019
Check List
--signoff
.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.