Preserve oldest snapshot when keep-within* does not collect enough

This commit is contained in:
Gautam Menghani 2023-06-17 18:04:35 +05:30 committed by Michael Eischer
parent 3888c21a27
commit 8da5a6649b
2 changed files with 17 additions and 1 deletions

View File

@ -278,7 +278,7 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
if cur.Time.After(t) { if cur.Time.After(t) {
val := b.bucker(cur.Time, nr) val := b.bucker(cur.Time, nr)
if val != b.Last { if val != b.Last || nr == len(list)-1 {
debug.Log("keep %v, time %v, ID %v, bucker %v, val %v %v\n", b.reason, cur.Time, cur.id.Str(), i, val, b.Last) debug.Log("keep %v, time %v, ID %v, bucker %v, val %v %v\n", b.reason, cur.Time, cur.id.Str(), i, val, b.Last)
keepSnap = true keepSnap = true
bucketsWithin[i].Last = val bucketsWithin[i].Last = val

View File

@ -44,6 +44,11 @@
"time": "2014-11-22T10:20:30Z", "time": "2014-11-22T10:20:30Z",
"tree": null, "tree": null,
"paths": null "paths": null
},
{
"time": "2014-08-08T10:20:30Z",
"tree": null,
"paths": null
} }
], ],
"reasons": [ "reasons": [
@ -152,6 +157,17 @@
"yearly within 9999y" "yearly within 9999y"
], ],
"counters": {} "counters": {}
},
{
"snapshot": {
"time": "2014-08-08T10:20:30Z",
"tree": null,
"paths": null
},
"matches": [
"yearly within 9999y"
],
"counters": {}
} }
] ]
} }