-
Notifications
You must be signed in to change notification settings - Fork 129
Description
What is the bug?
In Snapshot Management (SM) deletion-only policies, when a snapshotPattern
is configured in the deletion configuration, the snapshot retrieval fails with SnapshotMissingException
even though matching snapshots exist in the repository.
The root cause is that comma-separated snapshot patterns (e.g., "policy-name*,snp*"
) are being passed as a single string to OpenSearch's GetSnapshotsRequest.snapshots()
API instead of being split into separate array elements. This causes the API to search for a snapshot literally named "policy-name*,snp*"
rather than searching for snapshots matching either "policy-name*"
OR "snp*"
.
How can one reproduce the bug?
Steps to reproduce the behavior:
- Create a snapshot repository with some test snapshots (e.g.,
snp-test-1
,snp-test-2
) - Create an SM policy with deletion-only configuration:
{ "policy_name": "unified-ingestion-snapshot-delete", "deletion": { "schedule": { "cron": { "expression": "* * * * *", "timezone": "America/Los_Angeles" } }, "condition": { "max_age": "1m", "min_count": 1 }, "time_limit": "3h", "snapshot_pattern": "snp*" }, "snapshot_config": { "repository": "repo" } }
- Wait for the deletion workflow to trigger
- Check the logs and observe the warning message:
even though snapshots matching
No snapshots found under policy while getting snapshots to decide which snapshots to delete.
snp*
exist in the repository
What is the expected behavior?
The deletion workflow should:
- Successfully retrieve snapshots matching either the policy name pattern (
unified-ingestion-snapshot-delete*
) or the additional snapshot pattern (snp*
) - Filter snapshots based on the deletion condition (max_age, min_count, max_count)
- Delete eligible snapshots according to the policy configuration
- Not throw
SnapshotMissingException
when matching snapshots exist in the repository
What is your host/environment?
- OS: [e.g. macOS, Linux]
- OpenSearch Version: 2.19.x or later
- Plugin: opensearch-index-management
Do you have any screenshots?
N/A - This is a backend logic issue visible in the logs.
Do you have any additional context?
Technical Details:
The bug exists in SMUtils.kt
in the getSnapshots(name: String, repo: String)
function:
Problematic Code (Before Fix):
suspend fun Client.getSnapshots(name: String, repo: String): List<SnapshotInfo> {
val req = GetSnapshotsRequest()
.snapshots(arrayOf(name)) // Passes "pattern1*,pattern2*" as single element
.repository(repo)
// ...
}