对 ONTAP S3 删除 boto3 分页对象会将对象保留在存储分段中
适用场景
- ONTAP 9
- 基于 boto3 库的 S3 客户端
- 要一次性删除存储分段中的 1000 多个对象
问题描述
- 运行以下 python 脚本时,如果对象数大于 1000 个对象,则会将对象保留在存储分段中
obj.delete()
但是,在注释掉该行时,将列出所有对象
#!/usr/bin/python
import boto3
import logging
import sys
import botocore
logging.getLogger('boto3').setLevel(logging.DEBUG)
logging.getLogger('botocore').setLevel(logging.DEBUG)
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
s3 = boto3.resource('s3', endpoint_url='https://svm-s3.local:443', aws_access_key_id='user',aws_secret_access_key='secret')
bucket = s3.Bucket('user-bucket-1')
for obj in bucket.objects.all():
print("Will delete:", obj)
print("response:", obj.delete())