Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fill s3 tags before copying to log env #1031

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions postgres-appliance/scripts/configure_spilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,9 @@ def write_log_environment(placeholders):
if not os.path.exists(log_env['LOG_ENV_DIR']):
os.makedirs(log_env['LOG_ENV_DIR'])

tags = json.loads(os.getenv('LOG_S3_TAGS'))
log_env['LOG_S3_TAGS'] = "&".join(f"{key}={os.getenv(value)}" for key, value in tags.items())

for var in ('LOG_TMPDIR',
'LOG_SHIP_HOURLY',
'LOG_AWS_REGION',
Expand Down
6 changes: 3 additions & 3 deletions postgres-appliance/scripts/upload_pg_log_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import boto3
import os
import json
import logging
import subprocess
import sys
Expand Down Expand Up @@ -63,11 +64,10 @@ def upload_to_s3(local_file_path):

chunk_size = 52428800 # 50 MiB
config = TransferConfig(multipart_threshold=chunk_size, multipart_chunksize=chunk_size)
tags = eval(os.getenv('LOG_S3_TAGS'))
s3_tags_str = "&".join(f"{key}={os.getenv(value)}" for key, value in tags.items())

try:
bucket.upload_file(local_file_path, key_name, Config=config, ExtraArgs={'Tagging': s3_tags_str})
bucket.upload_file(local_file_path, key_name, Config=config,
ExtraArgs={'Tagging': json.loads(os.getenv('LOG_S3_TAGS'))})
FxKu marked this conversation as resolved.
Show resolved Hide resolved
except S3UploadFailedError as e:
logger.exception('Failed to upload the %s to the bucket %s under the key %s. Exception: %r',
local_file_path, bucket_name, key_name, e)
Expand Down
Loading