Add support in SM Plugin to delete snapshots created manually#1452
Conversation
86b255b to
933c487
Compare
|
Hey @bowenlan-amzn — since you were involved in the original issue, would you be open to reviewing the PR when you get a chance? Appreciate your insights! |
|
Will find time to do a review |
bowenlan-amzn
left a comment
There was a problem hiding this comment.
Overrall looks pretty good!
I think as long as user only use the deletion-only policy after fully upgraded. There shouldn't be any issue. We can call this out in the documentation.
It's unfortunate we don't have code coverage, for some reason it hasn't been working for a long time. But I can see tests being added.
...in/org/opensearch/indexmanagement/snapshotmanagement/engine/states/creation/CreatingState.kt
Outdated
Show resolved
Hide resolved
...in/org/opensearch/indexmanagement/snapshotmanagement/engine/states/deletion/DeletingState.kt
Outdated
Show resolved
Hide resolved
Yes, I'll update opensearch documentation after this PR is merged to use deletion-only policy after fully upgrading cluster.
Adding a ci check for code coverage (or preferrably new line changes) would be nice, it would ensure that tests are covering all cases. |
461d4d8 to
9f464fb
Compare
|
These CI failures look unrelated to this change, Other integration tests are failing which are not being reproduced in local environment. |
… manually Signed-off-by: Tarun-kishore <tarun2kishore@gmail.com>
Signed-off-by: Tarun-kishore <tarun2kishore@gmail.com>
Signed-off-by: Tarun-kishore <tarun2kishore@gmail.com>
28d1e94 to
efbdcc8
Compare
Signed-off-by: Tarun-kishore <tarun2kishore@gmail.com>
efbdcc8 to
a1a3097
Compare
|
Hi @bowenlan-amzn, I've updated version check to |
|
Hi @bowenlan-amzn , gentle ping for review |
bowenlan-amzn
left a comment
There was a problem hiding this comment.
Thanks, left some comments. Let's target get this in for 3.3 which is by this month I remember.
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/model/SMMetadata.kt
Outdated
Show resolved
Hide resolved
...earch/indexmanagement/snapshotmanagement/engine/states/creation/CreationConditionMetState.kt
Outdated
Show resolved
Hide resolved
...earch/indexmanagement/snapshotmanagement/engine/states/creation/CreationConditionMetState.kt
Outdated
Show resolved
Hide resolved
...in/org/opensearch/indexmanagement/snapshotmanagement/engine/states/deletion/DeletingState.kt
Outdated
Show resolved
Hide resolved
| val policySnapshots = getSnapshotsRes.snapshots | ||
|
|
||
| // Get pattern-based snapshots if pattern is specified | ||
| val patternSnapshotsResult = DeletionStateUtils.getPatternSnapshots(context, metadataBuilder) |
There was a problem hiding this comment.
Can we reuse logic from existing getSnapshots please.
And can we combine these 2 calls into one?
There was a problem hiding this comment.
Updated to use getSnapshots,
If we want to use single call, we'll have to make a call for sm-policy-name*,snapshot-pattern* pattern, which will return snapshots matching both of them, but then we'll need to decide which snapshot to filter based on policy, which increase computation on SM logic.
What do you prefer, single call with slightly more computation for prefix matching or two calls without any need to prefix matching in SM code?
There was a problem hiding this comment.
I think we can only define one condition for deletion. I am refering this doc.
So the same filtering logic apply to all the snapshots, then I don't feel there would be much overhead on SM side.
Please correct if I misunderstood sth.
There was a problem hiding this comment.
Currently, deletion supports deleting snapshot made by SM policy, It does that by getting snapshots with pattern policy-name* and checking if they are made by the policy or not.
This feature adds a new inputsnapshotPattern to deletion, which will delete snapshots with specified pattern irrespective of policy. This input is an addition to already deletion feature where snapshots by current policy are deleted.
These two deletion has difference of filtering, In first one (deletion of snapshot made by policy), we have filtering, while we don't have it in second one (snapshot specified by pattern input).
I hope this clears up any confusion.
There was a problem hiding this comment.
Thanks, I just remember this. We are refering to this filterBySMPolicyInSnapshotMetadata.
I think using one call is better, easier to handle the failure and retry, also network call is bigger overhead.
Can modify this filtering to only on the snapshots started with policy name I guess.
There was a problem hiding this comment.
Updated to use single call for getting snapshot instead of two.
...pensearch/indexmanagement/snapshotmanagement/engine/states/deletion/DeletionFinishedState.kt
Outdated
Show resolved
Hide resolved
...pensearch/indexmanagement/snapshotmanagement/engine/states/deletion/DeletionFinishedState.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SMRunner.kt
Show resolved
Hide resolved
Signed-off-by: Tarun-kishore <tarun2kishore@gmail.com>
|
Addressed comments, I do see CI failure but those seems to be unrelated to this change. |
Signed-off-by: Tarun-kishore <tarun2kishore@gmail.com>
96fe81c to
251cb4d
Compare
|
Hi @bowenlan-amzn, gentle ping for review. |
...pensearch/indexmanagement/snapshotmanagement/engine/states/deletion/DeletionFinishedState.kt
Outdated
Show resolved
Hide resolved
...in/org/opensearch/indexmanagement/snapshotmanagement/engine/states/deletion/DeletingState.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SMUtils.kt
Outdated
Show resolved
Hide resolved
|
@vikasvb90 could use a second eye here, please review if you or anyone get time. Plan to merge in by next Monday to catch 3.3. |
Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: Tarun Kishore <75606327+Tarun-kishore@users.noreply.github.com>
|
@Tarun-kishore will fix the build by this weekend and update this PR #1491 |
1a4416b
into
opensearch-project:main
This commit updated documentation for snapshot management API to include feature introduced in opensearch-project/index-management#1452 Signed-off-by: Tarun Kishore <75606327+Tarun-kishore@users.noreply.github.com>
|
First of all, thank you for providing the feature I was looking for !! Can you give me HTTP Request example for delete-only policy? Here is my test reqeust but it seems like it doesn't work. opensearch version: 3.3.2 POST _plugins/_sm/policies/deletion_only_policy I have three snapshots and all the snapshots made by index management policy. (not snapshot management, so policy field emptyed) Opensearch Log: No snapshots found under policy while getting snapshots to decide which snapshots to delete. I expected snapshots created before 1 hour ago would be deleted as soon as I created the delete-only policy but none of the snapshots were deleted And the delete request is okay in Dev tools, but the error occurred when I clicked snapshot management in openserach Dashboard after delete policy created.
|
|
Your policy looks correct. There was a bug which was causing the
For a delete-only policy, the only relevant field in snapshot_config is the repository. However, I don’t think it should be separated. In most cases, creation and deletion are expected to use the same repository, and introducing a separate deletion-specific config would create ambiguity around priority. Keeping a single snapshot_config keeps the model simple and avoids those conflicts. |
|
Thanks for the very quick reply!! It seems like the bug fix change not released yet and I have to wait release 3.4 to use delete-only policy, right? And the title of #1503 says 'comma-seperated', but does that mean nothing gets removed regardless of commas? I'm asking because my snapshot_pattern regex doesn't include any commas. Regarding the repository field, I also think creation and deletion are expected to use the same repository. So the structure I thought was {
"repository": {}
"creation": {
"snapshot_config": {}
}
"deletion": {}
}But it's not a big issue, so you can just ignore what I said. I just wanted to mention it. |
|
@4orty During deletion, policy snapshots are added by default. So, if your policy name is |
…arch-project#1452) Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com>
Description
This PR introduces optional creation workflows and snapshot pattern support for Snapshot Management policies, enabling users to create deletion-only policies and manage external snapshots alongside policy-created ones.
Key Changes
1. Optional Creation Field
creationfield optional inSMPolicy, allowing deletion-only policiesVersion.V_3_2_0) for backward compatibility2. Snapshot Pattern Support
snapshotPatternfield toSMPolicy.Deletionto include external snapshots in deletion workflows3. Enhanced State Machine Logic
DeletingStateto retrieve and combine snapshots from both policy and pattern sourcesDeletionFinishedStateto handle completion logic for pattern-based deletions4. Index Mapping Updates
snapshot_patternfield to deletion properties in index mappingsUse Cases Enabled
Backward Compatibility
All changes are fully backward compatible:
Testing
Comprehensive test coverage including:
Related Issues
Resolves #867
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.