deis / postgres

A PostgreSQL database used by Deis Workflow.
https://deis.com
MIT License
36 stars 22 forks source link

upgrading from v2.8.0 to v2.9.0 on S3 causes BucketAlreadyOwnedByYou error #173

Closed bacongobbler closed 7 years ago

bacongobbler commented 7 years ago

In v2.8.0 and in previous versions, we erroneously created the database bucket in the default us-east-1 region regardless of the set region. In v2.9.0 we corrected this, but when you upgrade from v2.8.0 to v2.9.0 you are greeted with this error:

/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/002_create_bucket.sh
Traceback (most recent call last):
  File "/bin/create_bucket", line 28, in <module>
    conn.create_bucket(bucket_name, location=region)
  File "/usr/local/lib/python3.5/dist-packages/boto/s3/connection.py", line 624, in create_bucket
    response.status, response.reason, body)
boto.exception.S3CreateError: S3CreateError: 409 Conflict
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>BucketAlreadyOwnedByYou</Code><Message>Your previous request to create the named bucket succeeded and you already own it.</Message><BucketName>workflow-database-29</BucketName><RequestId>B949AE55E09300BE</RequestId><HostId>7vVUWxtbxxrSBKPEqPQnzdFFCnMdC4mmLrCnKmbU05nz4tjcdk/BWSGATVuFoUN9sO/It4sH9X4=</HostId></Error>

This is because the bucket lookup code now logs into the specified region, and becuase it is not there it is not found. When boto attempts to create the bucket, it is met with this error because the bucket already exists in another region.