From 7a904a23392212d89bae30dded1011c5af65d336 Mon Sep 17 00:00:00 2001 From: Ben Simon Hartung <42031100+bentsku@users.noreply.github.com> Date: Wed, 13 Sep 2023 04:01:15 +0200 Subject: [PATCH] check bucket locking status before clean up (#285) --- pkg/bench/benchmark.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/bench/benchmark.go b/pkg/bench/benchmark.go index a53eb79f..87079cbd 100644 --- a/pkg/bench/benchmark.go +++ b/pkg/bench/benchmark.go @@ -215,7 +215,13 @@ func (c *Common) deleteAllInBucket(ctx context.Context, prefixes ...string) { } }() - errCh := cl.RemoveObjects(ctx, c.Bucket, objectsCh, minio.RemoveObjectsOptions{GovernanceBypass: true}) + delOpts := minio.RemoveObjectsOptions{} + _, _, _, errLock := cl.GetBucketObjectLockConfig(ctx, c.Bucket) + if errLock == nil { + delOpts.GovernanceBypass = true + } + + errCh := cl.RemoveObjects(ctx, c.Bucket, objectsCh, delOpts) for err := range errCh { if err.Err != nil { c.Error(err.Err)