Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Paginator to Recursively Delete All Objects Before Delete Bucket #631

Merged

Conversation

zliang-akamai
Copy link
Member

@zliang-akamai zliang-akamai commented Jul 31, 2024

📝 Description

  • Fixed issues:
    • A ClientError happens in the S3 client doesn't have any error message output
    • Versioned buckets containing objects can't be deleted recursively
    • Buckets containing more than 1000 objects can't be deleted recursively

✔️ How to Test

Automated Testing

pytest tests/integration/obj/test_obj_plugin.py -k "test_large_number_of_files_single_bucket"

Manual Testing

You can create these objects and buckets with OpenTofu/Terraform, but they will run for a very long time to create 2010 objects.

tofu apply -parallelism=100
provider "linode" {
  obj_bucket_force_delete = true
}

resource "linode_object_storage_bucket" "nonversioned-bucket" {
  region = "us-mia"
  label  = "test-cli-recursive-rb1"
}

resource "linode_object_storage_bucket" "versioned-bucket" {
  region = "us-mia"
  label  = "test-cli-recursive-rb2"
  versioning = true
}

resource "linode_object_storage_key" "foobar" {
  label   = "my-key"
}

resource "linode_object_storage_object" "objects" {
  count  = 1005
  bucket = linode_object_storage_bucket.nonversioned-bucket.label
  region = linode_object_storage_bucket.nonversioned-bucket.region
  key    = "myobj-${count.index}"

  access_key = linode_object_storage_key.foobar.access_key
  secret_key = linode_object_storage_key.foobar.secret_key

  content          = "haha"
  content_type     = "text/plain"
  content_language = "en"
}

resource "linode_object_storage_object" "versioned-objects" {
  count  = 1005
  bucket = linode_object_storage_bucket.versioned-bucket.label
  region = linode_object_storage_bucket.versioned-bucket.region
  key    = "myobj-${count.index}"

  access_key = linode_object_storage_key.foobar.access_key
  secret_key = linode_object_storage_key.foobar.secret_key

  content          = "haha"
  content_type     = "text/plain"
  content_language = "en"
}

And then remove them via CLI:

linode obj rb test-cli-recursive-rb1 --recursive;
linode obj rb test-cli-recursive-rb2 --recursive;

@zliang-akamai zliang-akamai requested a review from a team as a code owner July 31, 2024 07:02
@zliang-akamai zliang-akamai requested review from yec-akamai and ezilber-akamai and removed request for a team July 31, 2024 07:02
Copy link
Contributor

@ezilber-akamai ezilber-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Tests passing locally.

Copy link
Contributor

@lgarber-akamai lgarber-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integration tests are passing locally using make install && make MODULE=obj testint, great work!

@zliang-akamai zliang-akamai merged commit 8949bb8 into linode:dev Aug 5, 2024
6 checks passed
@zliang-akamai zliang-akamai deleted the zhiwei/fix-recursive-bucket-removal branch August 5, 2024 21:10
@zliang-akamai zliang-akamai added the bugfix for any bug fixes in the changelog. label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix for any bug fixes in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants