Athens: In gcp we ignore bkt.Create "bucket already exists" error

Created on 18 Nov 2018  路  4Comments  路  Source: gomods/athens

Describe the bug
This drove me mad while trying to test https://github.com/gomods/athens/issues/829 .

Here https://github.com/gomods/athens/blob/master/pkg/storage/gcp/gcp.go#L46

    if err != nil && !bucketExistsErr(err) {
        return nil, errors.E(op, err)
    }

we skip the error, assuming that if the bucket is already there it is because we created it.
Today I learned that the name must be unique across all GCP (see https://cloud.google.com/storage/docs/naming - "bucket name considerations) and here https://stackoverflow.com/questions/25127112/google-cloud-storage-static-bucketname-not-available .
So, if somebody else already picked up that bucket name, athens won't work and all the attempts to create / edit / delete will fail.

Error Message
All the calls return errors like '[email protected] does not have storage.objects.get access to .. "

To Reproduce
Try to open a gcp storage with athens-test as bucket name.

Expected behavior
We should skip creating the bucket only if it exists in our project and stop ignoring http.StatusConflict error.
Instead of checking the error, we should use https://godoc.org/cloud.google.com/go/storage#Client.Buckets to check for the existence of that bucket in the project we are targeting.

bug storage

Most helpful comment

Maybe we should drop creating Bucket and let user create it manualy from GCP panel? From permission perspective I think to create new Bucket you need to have higher permission, then just to read/create from specific Bucket. Then we can just check if given bucket exist and return err if not.

All 4 comments

Maybe we should drop creating Bucket and let user create it manualy from GCP panel? From permission perspective I think to create new Bucket you need to have higher permission, then just to read/create from specific Bucket. Then we can just check if given bucket exist and return err if not.

I will take this! :slightly_smiling_face:

@t-tomalak when you do this, can you check if the behavior is consistent across all the bucket storage implementations? For example, if you change GCP to require users to create the bucket beforehand, but S3 and Azure storage still try to automatically create, can you please create new issues for those storages, so we can update those implementations as well?

@arschles we don't create new bucket in S3 and azure implementation. I remember that we discussed this when I was implementing S3 storage that we wanna only create bucket when executing tests ( for storage.S3 is it in minio)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chriscoffee picture chriscoffee  路  3Comments

arschles picture arschles  路  3Comments

robjloranger picture robjloranger  路  3Comments

arschles picture arschles  路  3Comments

leitzler picture leitzler  路  3Comments