Skip to content

[BUG] SM deletion fails to find snapshots when using snapshot_pattern with comma-separated values #1502

@Tarun-kishore

Description

@Tarun-kishore

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:

  1. Create a snapshot repository with some test snapshots (e.g., snp-test-1, snp-test-2)
  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"
      }
    }
  3. Wait for the deletion workflow to trigger
  4. Check the logs and observe the warning message:
    No snapshots found under policy while getting snapshots to decide which snapshots to delete.
    
    even though snapshots matching snp* exist in the repository

What is the expected behavior?

The deletion workflow should:

  1. Successfully retrieve snapshots matching either the policy name pattern (unified-ingestion-snapshot-delete*) or the additional snapshot pattern (snp*)
  2. Filter snapshots based on the deletion condition (max_age, min_count, max_count)
  3. Delete eligible snapshots according to the policy configuration
  4. 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)
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions