Add delete_snapshot option to ISM delete action for cleaning up searchable snapshot sources#1565
Conversation
…hable snapshot sources Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1565 +/- ##
==========================================
+ Coverage 76.39% 76.58% +0.18%
==========================================
Files 379 381 +2
Lines 17942 18130 +188
Branches 2479 2516 +37
==========================================
+ Hits 13707 13885 +178
+ Misses 2974 2973 -1
- Partials 1261 1272 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This comment was marked as resolved.
This comment was marked as resolved.
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
|
I realized my previous comment was based on a misunderstanding. I've now added an integration test ( |
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
|
The CI failed due to a timeout.
The added integration test passes locally in 1 ~ 2 minutes. I'm not sure if this is related to my changes or a pre-existing issue. |
|
@lawofcycles commented on Jan 12, 2026, 12:49 AM PST:
Hi, please feel free to update the |
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
60a4e85 to
995aba9
Compare
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
@bowenlan-amzn |
|
If the snapshot for a ISM-managed remote index (backed by a snapshot) is not just for that one index, I think it's better to use snapshot management to manage the lifecycle of that snapshot, instead of index state management. ISM generally only works on single index level. |
|
@bowenlan-amzn Thank you for the feedback. I want to make sure I understand your concern correctly.
My current implementation only deletes a snapshot when no other indices are using it. If multiple indices share the same snapshot, the snapshot deletion is skipped entirely. I'm open to exploring alternative approaches to Snapshot Management based on your guidance. |
|
@lawofcycles commented on Jan 24, 2026, 7:54 PM PST:
1:1 index-to-snapshot relationship makes sense and I can see that's what you are trying to achieve here. |
|
|
||
| if (action.deleteSnapshot) { | ||
| try { | ||
| val settingsResponse = getIndexSettings(indexName) |
There was a problem hiding this comment.
Seems we can directly read the setting from cluster state object, so don't need to make a network call for that.
There was a problem hiding this comment.
Thanks, updated to read settings from cluster state directly.
234f71f
|
@bowenlan-amzn Thank you for the suggestion. Let me describe the use case I'm trying to address, so we can discuss whether the existing SM deletion-only policy can cover it. Use case (from #1476) A typical Hot -> Warm (searchable snapshot) -> Delete lifecycle managed by a ISM policy
The problem is that step 3 only deletes the index, not the underlying snapshot in the repository. I looked into using an SM deletion-only policy with This means that if the SM deletion schedule runs before ISM deletes the searchable snapshot index, SM could delete a snapshot that is still actively backing a mounted index, making that index's data inaccessible. Since ISM controls the index lifecycle, it knows exactly when the index is no longer needed, so triggering the snapshot cleanup at the point of index deletion would avoid this timing issue. I would appreciate your thoughts on how to best address this use case. |
|
@lawofcycles commented on Feb 9, 2026, 3:54 PM PST:
Your use case involves a 1:1 mapping between snapshots and indices. In ISM, we can implement this by storing the snapshot name in the managed index metadata after successful completion, then reading and deleting that specific snapshot during the delete step. The snapshot management feature differs—it creates snapshots for index groups on a time-based schedule. Deletion retains only the latest snapshots (at minimum, the most recent one) rather than removing all snapshots. However, it's unclear whether this approach works for searchable indices—specifically, whether a searchable index must bind to one specific snapshot or can function with any snapshot containing it. Could you check this once you got time, thanks! |
@bowenlan-amzn I looked into the binding behavior of searchable snapshot indices. Here are my findings from testing on OpenSearch 3.5.0. 1. Searchable snapshots are hard bound to a specific snapshot The binding is at the UUID level, so the index cannot function with a different snapshot, even if that snapshot contains the same data. 2. OpenSearch protects the bound snapshot from deletion Attempting to delete 3. SM deletion policy behavior with searchable snapshot bound snapshots |
…instead of network call Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
|
@lawofcycles appreciate your time spent this research! To clear the expected user experience:
The constraint here is one snapshot created for one index. So we don't need to worry about this snapshot used by other index so don't have to check any of that. Snapshot management seems still usable here to back a group of indexes, but it feels hard for ISM |
Description
This PR adds a new optional
delete_snapshotparameter to the ISM delete action. When enabled, it automatically deletes the source snapshot of a searchable snapshot index along with the index itself.use case
Hot → Warm (searchable snapshot) → Delete lifecycle where both the index and underlying snapshot should be removed to free up storage.
format
behavior
delete_snapshot: trueand the index is a searchable snapshot, both the index and its source snapshot are deletedfalsefor backward compatibilityIn addition to unit tests, I manually tested with local build.
Related Issues
Resolves #1476
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.