SLM acts as min_count =0 when Minimum number of snapshots is not specified
When user doesn't specify the min_count in a SLM policy, SLM acts as min_count =0, which means the minimum number of snapshots to retain is zero. It will cause all snapshots to get deleted.
The default value for optional setting - min_count is not documented in the SLM policy document.
The code doesn't accept the min_count below 1.
Code
if (this.minimumSnapshotCount != null && this.minimumSnapshotCount < 1) {
throw new IllegalArgumentException("minimum snapshot count must be at least 1, but was: " + this.minimumSnapshotCount);
}
if (this.maximumSnapshotCount != null && this.maximumSnapshotCount < 1) {
throw new IllegalArgumentException("maximum snapshot count must be at least 1, but was: " + this.maximumSnapshotCount);
}
if ((maximumSnapshotCount != null && minimumSnapshotCount != null) && this.minimumSnapshotCount > this.maximumSnapshotCount) {
throw new IllegalArgumentException(
"minimum snapshot count "
+ this.minimumSnapshotCount
+ " cannot be larger than maximum snapshot count "
+ this.maximumSnapshotCount
);
}
min_count default value being 0 is an unexpected behavior as the logic in the API validation doesn't allow user to set it below 1. This default value will cause data loss as all snapshots will be deleted.
The questions in this issue
Whether to change the default value to 1 as it would make more sense, given min_count=0 is against what we allow in Elasticsearch API.
Elasticsearch Version
8.12.2
Installed Plugins
No response
Java Version
bundled
OS Version
NA
Problem Description
SLM acts as min_count =0 when Minimum number of snapshots is not specified
When user doesn't specify the min_count in a SLM policy, SLM acts as min_count =0, which means the minimum number of snapshots to retain is zero. It will cause all snapshots to get deleted.
min_count
is not documented in the SLM policy document.min_count
default value being 0 is an unexpected behavior as the logic in the API validation doesn't allow user to set it below 1. This default value will cause data loss as all snapshots will be deleted.The questions in this issue
min_count=0
is against what we allow in Elasticsearch API.retention
(c.f https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html#slm-api-put-request-body)?Steps to Reproduce
create a test v8.12.2 environment on ESS
generate some snapshots by manually running the default [cloud-snapshot-policy] SLM policy
modify the default policy by removing the
min_count
e.g. API query# the
expire_after
is set to 5m to speed up the reproducing.Wait till the SLM snapshot retention executed, verify that all snapshots got deleted.
Logs (if relevant)
No response