mirror of
https://github.com/pgsty/minio.git
synced 2026-11-10 17:45:32 +03:00
fix(ilm): report refused purges of all versions, and account their keys
An expiry of all versions of a key purges exactly that key, and the purge can refuse it or stop early. Those outcomes were hard to see, and the scanner reported a key it had queued as if it were already gone. - Refusals and failures of a purge are counted in expiry_incomplete_total with their own reasons: tier_unsupported (a version is in a remote tier), budget (stopped after progress; the next expiry continues), changed (the latest version a batch matched changed) and history_unavailable. They are traced with the reason and send no removal event. A partial purge keeps its audit record, now with the reason. A tier refusal is also logged, once per key and hour, in words. - A drive that cannot be read or decoded during the purge's own drive check now returns errDeleteAllHistoryUnavailable, which names the cause and stays a write quorum error (503) for API callers. - The scanner does not queue an expiry of all versions whose latest version is hot when the pool holds a version in a remote tier: the purge would refuse it each cycle. It counts each such observation as tier_unsupported_skipped, once per drive scanner and cycle. A tiered version only another pool holds is unknown here, so the purge still decides; a transitioned latest version keeps the transitioned expiry. The tier predicate is shared with the purge's own check, for FileInfo and ObjectInfo, and excludes free versions. - The scanner accounts every version of a key under an expiry of all versions at its size, queued or not, instead of as already removed. Usage, and so hard quota, drops after a fresh scan of the subtree once the purge succeeded. The alerts on many or large versions count the versions of a key that is not queued. - A lifecycle expiry never deletes a prefix: DeleteObject refuses DeletePrefix with Expiration.Expire as InvalidArgument. No caller sends it since expiries of all versions became purges; a force delete of a prefix is unchanged. Not done from the plan: queuing an MRF heal per version when a drive's xl.meta fails to decode. Object heal does not rewrite metadata that fails its CRC check (it reports the drive as unknown and skips it), so those heals would not repair the drive. Such a key stays refused until its metadata on that drive is repaired. Tests: TestPurgeAllVersionsRefusalReasons, TestPurgeAllVersionsRefusesCorruptDrive, TestScannerSkipsDeleteAllForTieredKey and TestPoolsDeleteObjectRejectsExpirePrefix are new. Tests that expected the scanner to queue a refused purge, the predictive accounting, or the old prefix options are converted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
@@ -539,6 +539,10 @@ func TestPoolsLifecycleLegacyHistory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// authorityDeleteAll is the expiry of all versions of a key as the expiry
|
||||
// worker sends it: a purge of all versions, approved by the lifecycle.
|
||||
var authorityDeleteAll = ObjectOptions{DeleteAllVersions: true, Expiration: ExpirationOptions{Expire: true}}
|
||||
|
||||
// A fresh version committed to 15 of 16 drives, with eight other drives
|
||||
// unreadable: only seven answering drives show it.
|
||||
func TestPoolsLifecyclePartialHistory(t *testing.T) {
|
||||
@@ -554,7 +558,7 @@ func TestPoolsLifecyclePartialHistory(t *testing.T) {
|
||||
if _, _, err := s.z.lifecycleEventsAllPools(ctx, s.bucket, key); !isErrReadQuorum(err) {
|
||||
t.Errorf("partial history: %v", err)
|
||||
}
|
||||
_, err := s.z.DeleteObject(ctx, s.bucket, key, ObjectOptions{Versioned: true, DeletePrefix: true, DeletePrefixObject: true, Expiration: ExpirationOptions{Expire: true}})
|
||||
_, err := s.z.DeleteObject(ctx, s.bucket, key, authorityDeleteAll)
|
||||
if !isErrWriteQuorum(err) {
|
||||
t.Errorf("DeleteAll on a partial history: %v", err)
|
||||
}
|
||||
@@ -615,7 +619,7 @@ func TestPoolsLifecycleMissingVersion(t *testing.T) {
|
||||
if _, _, err := s.z.lifecycleEventsAllPools(ctx, s.bucket, key); !isErrReadQuorum(err) {
|
||||
t.Errorf("history without an observed version: %v", err)
|
||||
}
|
||||
_, err := s.z.DeleteObject(ctx, s.bucket, key, ObjectOptions{Versioned: true, DeletePrefix: true, DeletePrefixObject: true, Expiration: ExpirationOptions{Expire: true}})
|
||||
_, err := s.z.DeleteObject(ctx, s.bucket, key, authorityDeleteAll)
|
||||
if !isErrWriteQuorum(err) {
|
||||
t.Errorf("DeleteAll: %v", err)
|
||||
}
|
||||
@@ -630,7 +634,6 @@ func TestPoolsLifecycleMissingVersion(t *testing.T) {
|
||||
// The completeness checks also hold where a set has fewer answering drives
|
||||
// than a read quorum or no version reaches one.
|
||||
func TestPoolsLifecycleHistoryEarlyReturns(t *testing.T) {
|
||||
deleteAll := ObjectOptions{Versioned: true, DeletePrefix: true, DeletePrefixObject: true, Expiration: ExpirationOptions{Expire: true}}
|
||||
|
||||
// Seven drives hold the key, the other nine do not have it at all.
|
||||
t.Run("minority-copy-only", func(t *testing.T) {
|
||||
@@ -648,7 +651,7 @@ func TestPoolsLifecycleHistoryEarlyReturns(t *testing.T) {
|
||||
if _, _, err := s.z.lifecycleEventsAllPools(ctx, s.bucket, key); !isErrReadQuorum(err) {
|
||||
t.Errorf("minority copy: %v", err)
|
||||
}
|
||||
if _, err := s.z.DeleteObject(ctx, s.bucket, key, deleteAll); !isErrWriteQuorum(err) {
|
||||
if _, err := s.z.DeleteObject(ctx, s.bucket, key, authorityDeleteAll); !isErrWriteQuorum(err) {
|
||||
t.Errorf("DeleteAll: %v", err)
|
||||
}
|
||||
for i := 9; i < len(disks); i++ {
|
||||
@@ -671,7 +674,7 @@ func TestPoolsLifecycleHistoryEarlyReturns(t *testing.T) {
|
||||
if _, _, err := s.z.lifecycleEventsAllPools(ctx, s.bucket, key); !isErrReadQuorum(err) {
|
||||
t.Fatalf("disjoint minorities: %v", err)
|
||||
}
|
||||
if _, err := s.z.DeleteObject(ctx, s.bucket, key, deleteAll); !isErrWriteQuorum(err) {
|
||||
if _, err := s.z.DeleteObject(ctx, s.bucket, key, authorityDeleteAll); !isErrWriteQuorum(err) {
|
||||
t.Fatalf("DeleteAll: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user