Skip to content

Commit

Permalink
fix(WARNING): MSG: WALE_S3_ENDPOINT defined, ignoring AWS_REGION
Browse files Browse the repository at this point in the history
  • Loading branch information
duanhongyi committed Nov 12, 2018
1 parent 50d89c3 commit 6c37b92
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ RUN apt-get purge -y --auto-remove $BUILD_DEPS && \
COPY rootfs /
ENV WALE_ENVDIR=/etc/wal-e.d/env
RUN mkdir -p $WALE_ENVDIR
RUN python3 /patcher-script.py
RUN python3 /patcher-script.py /bin/create_bucket
RUN python3 /patcher-script.py /usr/local/bin/wal-e

CMD ["/docker-entrypoint.sh", "postgres"]
EXPOSE 5432
4 changes: 2 additions & 2 deletions rootfs/bin/create_bucket
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def bucket_exists(conn, name):
return True

bucket_name = os.getenv('BUCKET_NAME')
region = os.getenv('AWS_REGION')
region = os.getenv('S3_REGION')

if os.getenv('DATABASE_STORAGE') == "s3":
conn = boto.s3.connect_to_region(region)
Expand Down Expand Up @@ -85,6 +85,6 @@ else:
port=int(os.getenv('S3_PORT')),
calling_format=OrdinaryCallingFormat())
# HACK(bacongobbler): allow boto to connect to minio by changing the region name for s3v4 auth
conn.auth_region_name = os.getenv('AWS_REGION')
conn.auth_region_name = os.getenv('S3_REGION')
if not bucket_exists(conn, bucket_name):
conn.create_bucket(bucket_name)
2 changes: 1 addition & 1 deletion rootfs/docker-entrypoint-initdb.d/001_setup_envdir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if [[ "$DATABASE_STORAGE" == "s3" || "$DATABASE_STORAGE" == "minio" ]]; then
else
echo "1" > AWS_INSTANCE_PROFILE
fi
echo $AWS_REGION > AWS_REGION
echo $AWS_REGION > S3_REGION
echo $BUCKET_NAME > BUCKET_NAME
elif [ "$DATABASE_STORAGE" == "gcs" ]; then
GOOGLE_APPLICATION_CREDENTIALS="/var/run/secrets/deis/objectstore/creds/key.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def patch_wal_e_hmac_auth_v4_handler():
_init = HmacAuthV4Handler.__init__
def wrap_init(self, *args, **kwargs):
_init(self, *args, **kwargs)
self.region_name = os.getenv('AWS_REGION', self.region_name)
self.region_name = os.getenv('S3_REGION', self.region_name)
HmacAuthV4Handler.__init__ = wrap_init


Expand Down
10 changes: 6 additions & 4 deletions rootfs/patcher-script.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

patch_script = """
def run_patch_scripts(patch_script_path):
Expand All @@ -15,18 +17,18 @@ def run_patch_scripts(patch_script_path):
"""


def main():
def main(patch_file):
result_list = []
with open("/usr/local/bin/wal-e", "r") as f:
with open(patch_file, "r") as f:
has_patched = False
for line in f:
if not has_patched and line.startswith('import'):
result_list.append(patch_script)
has_patched = True
result_list.append(line)
with open("/usr/local/bin/wal-e", "w") as f:
with open(patch_file, "w") as f:
for line in result_list:
f.write(line)

if __name__ == '__main__':
main()
main(sys.argv[1])

0 comments on commit 6c37b92

Please sign in to comment.