storage: fix bucket cleanup
The bucket cleanup should remove any holds that exist on objects
to be cleaned up, so that deletion does not fail.
Fixes
@@ -3113,6 +3113,13 @@ func killBucket(ctx context.Context, client *Client, bucketName string) error {
if err != nil {
return err
}
+ // Objects with a hold must have the hold released.
+ if objAttrs.EventBasedHold || objAttrs.TemporaryHold {
+ obj := bkt.Object(objAttrs.Name)
+ if _, err := obj.Update(ctx, ObjectAttrsToUpdate{EventBasedHold: false, TemporaryHold: false}); err != nil {
+ fmt.Errorf("removing hold from %q: %v", bucketName+"/"+objAttrs.Name, err)
+ }
+ }
if err := bkt.Object(objAttrs.Name).Delete(ctx); err != nil {
return fmt.Errorf("deleting %q: %v", bucketName+"/"+objAttrs.Name, err)
}
