[Bug Fix] Fix snapshot pattern parsing in SM deletion workflow to handle comma-separated values #1503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a bug in the Snapshot Management (SM) deletion workflow where comma-separated snapshot patterns are incorrectly passed as a single string to the
GetSnapshotsRequest
API, causingSnapshotMissingException
even when matching snapshots exist in the repository.Problem:
When an SM deletion policy includes a
snapshot_pattern
field (e.g.,"snp*"
), the code concatenates it with the policy name pattern (e.g.,"policy-name*,snp*"
) and passes this as a single string element to the API. OpenSearch's GetSnapshots API then treats"policy-name*,snp*"
as a literal snapshot name rather than two separate patterns to match.Solution:
Modified the
getSnapshots(name: String, repo: String)
function inSMUtils.kt
to split comma-separated patterns into separate array elements before passing them toGetSnapshotsRequest.snapshots()
.Changes:
SMUtils.kt
to parse comma-separated snapshot patterns into separate array elementsDeletingState.kt
,DeletionStartState.kt
,DeletionConditionMetState.kt
, andDeletionFinishedState.kt
Impact:
snapshot_pattern
fieldBefore:
After:
Related Issues
Resolves #1502
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.