s3: check Object Lock on directory-marker keys before bucket deletion (#11096)

recursivelyCheckLocksWithClient tested EntryHasActiveLock only on
non-directory entries, so a directory-marker object (an S3 key ending
in "/") that carries retention or a legal hold was recursed into but
never lock-checked. DeleteBucket then saw no locks and removed the
bucket, destroying an object under active Object Lock along with the
rest of the bucket. DeleteObject already enforces the lock on the same
key, so the two paths disagreed.

Check the directory entry for an active lock before recursing.

Claude-Session: https://claude.ai/code/session_011QqNaxZwnpHgMoAZNp3RkY
This commit is contained in:
Chris Lu authored and GitHub committed 2026-09-02 11:35:19 -07:00
1 parent 3cdfe648eb
commit 23adeb37e2
2 files changed
+100

No files matched your search

@@ -153,6 +153,13 @@ func recursivelyCheckLocksWithClient(ctx context.Context, client filer_pb.Seawee
return false, err
}
} else {
// A directory-marker object (key ending in "/") is stored as a
// directory entry and can carry a lock, so check it before recursing.
if EntryHasActiveLock(entry, currentTime) {
*hasLocks = true
glog.V(2).Infof("Found directory marker with active lock: %s/%s", dir, entry.Name)
return true, nil
}
// Recursively check subdirectories
if err := recursivelyCheckLocksWithClient(ctx, client, subDir, hasLocks, currentTime); err != nil {
return false, err