fix: keep plain Enabled versioning when Object Lock is enabled on a bucket

Site adoption and ForceCreate preserved a suspended or prefix-excluded
versioning configuration while bootstrapping Object Lock, persisting a state
that PutBucketVersioning itself rejects: objects under an excluded prefix in
a WORM bucket were not versioned and escaped retention. enablePeerBucketVersioning
now takes the lock intent and replaces such configurations with plain Enabled
versioning, and metadata loading ignores prefix exclusions on a locked bucket
as it ignored suspension before. The adoption tests assert the normalized
state and keep the timestamp-preservation checks on valid documents.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PvgysXDmhPBBimCReYtA8q
Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
Feng Ruohang
2026-09-02 14:06:56 +08:00
parent 76195f1c68
commit 3b5de82f5a
4 changed files with 21 additions and 13 deletions
+2 -2
View File
@@ -911,7 +911,7 @@ func (z *erasureServerPools) MakeBucket(ctx context.Context, bucket string, opts
meta.SetCreatedAt(opts.CreatedAt)
}
if opts.LockEnabled {
if err := enablePeerBucketVersioning(&meta); err != nil {
if err := enablePeerBucketVersioning(&meta, true); err != nil {
return err
}
if len(meta.ObjectLockConfigXML) == 0 {
@@ -920,7 +920,7 @@ func (z *erasureServerPools) MakeBucket(ctx context.Context, bucket string, opts
}
}
if opts.VersioningEnabled {
if err := enablePeerBucketVersioning(&meta); err != nil {
if err := enablePeerBucketVersioning(&meta, opts.LockEnabled); err != nil {
return err
}
}