Skip to content

Commit 65e2a73

Browse files
committed
set AWS_S3_FORCE_PATH_STYLE accordingly
WAL-G will not work if we use our own endpoint that only supports path convention but AWS_S3_FORCE_PATH_STYLE is not set. This patch ensures that WAL-G and WAL-E will use the same convention. Also add support to WALE_S3_ENDPOINT with convention other than path. Signed-off-by: 胡玮文 <[email protected]>
1 parent 9f37ab4 commit 65e2a73

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

postgres-appliance/scripts/configure_spilo.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,20 @@ def write_wale_environment(placeholders, prefix, overwrite):
783783

784784
# for S3-compatible storage we want to specify WALE_S3_ENDPOINT and AWS_ENDPOINT, but not AWS_REGION
785785
if aws_endpoint or wale_endpoint:
786-
if not aws_endpoint:
787-
aws_endpoint = wale_endpoint.replace('+path://', '://')
788-
elif not wale_endpoint:
786+
convention = 'path'
787+
if not wale_endpoint:
789788
wale_endpoint = aws_endpoint.replace('://', '+path://')
789+
else:
790+
match = re.match(r'^(\w+)\+(\w+)(://.+)$', wale_endpoint)
791+
if match:
792+
convention = match.group(2)
793+
else:
794+
logging.warning('Invalid WALE_S3_ENDPOINT, the format is protocol+convention://hostname:port, '
795+
'but got %s', wale_endpoint)
796+
if not aws_endpoint:
797+
aws_endpoint = match.expand(r'\1\3') if match else wale_endpoint
790798
wale.update(WALE_S3_ENDPOINT=wale_endpoint, AWS_ENDPOINT=aws_endpoint, WALG_DISABLE_S3_SSE='true')
799+
wale['AWS_S3_FORCE_PATH_STYLE'] = 'true' if convention == 'path' else 'false'
791800
if aws_region and wale.get('USE_WALG_BACKUP') == 'true':
792801
wale['AWS_REGION'] = aws_region
793802
elif not aws_region:

0 commit comments

Comments
 (0)