Skip to content

Commit

Permalink
fixed bucket delete infinity looo.
Browse files Browse the repository at this point in the history
  • Loading branch information
h-r-k-matsumoto committed May 18, 2019
1 parent a650944 commit 1b37243
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/controller/gcs/gcs_operater.go
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"cloud.google.com/go/storage"
"google.golang.org/api/googleapi"
)

var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz0123456789")
Expand Down Expand Up @@ -66,5 +67,12 @@ func IfExistsBucket(ctx context.Context, client *storage.Client, projectID, buck
// DeleteBucket delete gcs bucket.
func DeleteBucket(ctx context.Context, client *storage.Client, bucketName string) error {
bkt := client.Bucket(bucketName)
return bkt.Delete(ctx)
err := bkt.Delete(ctx)
if e, ok := err.(*googleapi.Error); ok {
if e.Code == 404 {
//already deleted.
return nil
}
}
return err
}

0 comments on commit 1b37243

Please sign in to comment.