Skip to content

Commit

Permalink
Removing bucket deletion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zveinn committed Jan 8, 2024
1 parent 98c4e54 commit 8397688
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions functional_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,34 +223,29 @@ func cleanupBucket(bucketName string, c *minio.Client) error {
// Iterate over all objects in the bucket via listObjectsV2 and delete
for objCh := range c.ListObjects(context.Background(), bucketName, minio.ListObjectsOptions{Recursive: true}) {
if objCh.Err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", objCh.Err)
return objCh.Err
}
if objCh.Key != "" {
err := c.RemoveObject(context.Background(), bucketName, objCh.Key, minio.RemoveObjectOptions{})
if err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", err)
return err
}
}
}
for objPartInfo := range c.ListIncompleteUploads(context.Background(), bucketName, "", true) {
if objPartInfo.Err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", objPartInfo.Err)
return objPartInfo.Err
}
if objPartInfo.Key != "" {
err := c.RemoveIncompleteUpload(context.Background(), bucketName, objPartInfo.Key)
if err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", err)
return err
}
}
}
// objects are already deleted, clear the buckets now
err := c.RemoveBucket(context.Background(), bucketName)
if err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", err)
return err
}
return err
Expand All @@ -261,26 +256,22 @@ func cleanupVersionedBucket(bucketName string, c *minio.Client) error {
defer close(doneCh)
for obj := range c.ListObjects(context.Background(), bucketName, minio.ListObjectsOptions{WithVersions: true, Recursive: true}) {
if obj.Err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", obj.Err)
return obj.Err
}
if obj.Key != "" {
err := c.RemoveObject(context.Background(), bucketName, obj.Key,
minio.RemoveObjectOptions{VersionID: obj.VersionID, GovernanceBypass: true})
if err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", err)
return err
}
}
}
for objPartInfo := range c.ListIncompleteUploads(context.Background(), bucketName, "", true) {
if objPartInfo.Err != nil {
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", objPartInfo.Err)
return objPartInfo.Err
}
if objPartInfo.Key != "" {
err := c.RemoveIncompleteUpload(context.Background(), bucketName, objPartInfo.Key)
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", err)
if err != nil {
return err
}
Expand All @@ -291,9 +282,7 @@ func cleanupVersionedBucket(bucketName string, c *minio.Client) error {
if err != nil {
for obj := range c.ListObjects(context.Background(), bucketName, minio.ListObjectsOptions{WithVersions: true, Recursive: true}) {
log.Println("found", obj.Key, obj.VersionID)
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", err)
}
logError("bucket-cleanup", getFuncName(), nil, time.Now(), "", "", err)
return err
}
return err
Expand Down

0 comments on commit 8397688

Please sign in to comment.