Skip to main content
NetApp Knowledge Base

boto3 paginated object deletion against ONTAP S3 leaves objects in bucket

Views:
262
Visibility:
Public
Votes:
0
Category:
ontap-9
Specialty:
core
Last Updated:

Applies to

  • ONTAP 9
  • boto3 library based S3 client
  • more than 1000 objects in bucket are going to be deleted at once

Issue

 
  • Running the python script below, leaves objects in bucket when object count is greater than 1000 objects
  • When commenting out the obj.delete() line however, all objects are listed
#!/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.