跳转到主内容

对 ONTAP S3 删除 boto3 分页对象会将对象保留在存储分段中

Views:
25
Visibility:
Public
Votes:
0
Category:
ontap-9
Specialty:
CORE
Last Updated:

适用场景

  • 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())

 

Sign in to view the entire content of this KB article.

New to NetApp?

Learn more about our award-winning Support

NetApp provides no representations or warranties regarding the accuracy or reliability or serviceability of any information or recommendations provided in this publication or with respect to any results that may be obtained by the use of the information or observance of any recommendations provided herein. The information in this document is distributed AS IS and the use of this information or the implementation of any recommendations or techniques herein is a customer's responsibility and depends on the customer's ability to evaluate and integrate them into the customer's operational environment. This document and the information contained herein may be used solely in connection with the NetApp products discussed in this document.