{"id":1386,"date":"2019-07-19T07:48:39","date_gmt":"2019-07-19T12:48:39","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=1386"},"modified":"2019-07-19T07:48:41","modified_gmt":"2019-07-19T12:48:41","slug":"oci-bucket-delete-fail","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/oci-bucket-delete-fail\/","title":{"rendered":"OCI Bucket Delete Fail"},"content":{"rendered":"\n
If you have trouble deleting an object storage bucket in Oracle Cloud Infrastructure you may have to clear old multipart uploads. The message may look something like this: Bucket named 'DR-Validation' has pending multipart uploads. Stop all multipart uploads first.<\/strong><\/p>\n\n\n\n At the time the only way I could do this was through the API. Did not appear like the CLI or Console could clear out the upload. Below is a little python that may help. Below is an example just to show the idea. And of course if you have thousands of multipart uploads(yes its possible); you will need to change this was only for one or two.<\/p>\n\n\n <\/p>\n","protected":false},"excerpt":{"rendered":" If you have trouble deleting an object storage bucket in Oracle Cloud Infrastructure you may have to clear old multipart<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1386","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1386"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1386\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n#!\/usr\/bin\/python\n#: Script Name : lobjectparts.py\n#: Author : Riaan Rossouw\n#: Date Created : June 13, 2019\n#: Date Updated : July 18, 2019\n#: Description : Python Script to list multipart uploads\n#: Examples : lobjectparts.py -t tenancy -r region -b bucket\n#: : lobjectparts.py --tenancy <ocid> --region <region> --bucket <bucket>\n\n## Will need the api modules\n## new: https:\/\/oracle-cloud-infrastructure-python-sdk.readthedocs.io\/en\/latest\/\n## old: https:\/\/oracle-bare-metal-cloud-services-python-sdk.readthedocs.io\/en\/latest\/installation.html#install\n## https:\/\/oracle-cloud-infrastructure-python-sdk.readthedocs.io\/en\/latest\/api\/object_storage\/client\/oci.object_storage.ObjectStorageClient.html\n\nfrom __future__ import print_function\nimport os, optparse, sys, time, datetime\nimport oci\n\n__version__ = '0.9.1'\noptdesc = 'This script is used to list multipart uploads in a bucket'\n\nparser = optparse.OptionParser(version='%prog version ' + __version__)\nparser.formatter.max_help_position = 50\nparser.add_option('-t', '--tenancy', help='Specify Tenancy ocid', dest='tenancy', action='append')\nparser.add_option('-r', '--region', help='region', dest='region', action='append')\nparser.add_option('-b', '--bucket', help='bucket', dest='bucket', action='append')\n\nopts, args = parser.parse_args()\n\ndef showMultipartUploads(identity, bucket_name):\n object_storage = oci.object_storage.ObjectStorageClient(config)\n namespace_name = object_storage.get_namespace().data\n uploads = object_storage.list_multipart_uploads(namespace_name, bucket_name, limit = 1000).data\n print(' {:35} | {:15} | {:30} | {:35} | {:20}'.format('bucket','namespace','object','time_created','upload_id'))\n for o in uploads:\n print(' {:35} | {:15} | {:30} | {:35} | {:20}'.format(o.bucket, o.namespace, o.object, str(o.time_created), o.upload_id))\n confirm = input("Confirm if you want to abort this multipart upload (Y\/N): ")\n if confirm == "Y":\n response = object_storage.abort_multipart_upload(o.namespace, o.bucket, o.object, o.upload_id).data\n else:\n print ("Chose to not do the abort action on this multipart upload at this time...")\n\ndef main():\n mandatories = ['tenancy','region','bucket']\n for m in mandatories:\n if not opts.__dict__[m]:\n print ("mandatory option is missing\\n")\n parser.print_help()\n exit(-1)\n\n print ('Multipart Uploads')\n config['region'] = opts.region[0]\n identity = oci.identity.IdentityClient(config)\n showMultipartUploads(identity, opts.bucket)\n\nif __name__ == '__main__':\n config = oci.config.from_file("\/root\/.oci\/config","oci.api")\n main()\n<\/pre><\/div>\n\n\n