Skip to content

Commit

Permalink
fixing issues logging when cluster type is serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
DevanathanSabapathy1 committed Feb 5, 2024
1 parent f99a67a commit b68fe18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 15 additions & 1 deletion core/extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import zipfile
import time
import re
import common.config as config_helper
import common.log as log_helper
from common import aws_service as aws_service_helper
Expand All @@ -14,6 +15,16 @@

logger = logging.getLogger("WorkloadReplicatorLogger")

serverless_cluster_endpoint_pattern = (
r"(.+)\.(.+)\.(.+).redshift-serverless(-dev)?\.amazonaws\.com:[0-9]{4,5}\/(.)+"
)


def is_serverless(config):
return bool(
re.fullmatch(serverless_cluster_endpoint_pattern, config["source_cluster_endpoint"])
)


def main():

Expand Down Expand Up @@ -66,7 +77,10 @@ def main():
if config.get("source_cluster_endpoint"):
application = "WorkloadReplicator-Extract"

host = config.get("source_cluster_endpoint").split(".")[0]
if is_serverless(config):
host = f'redshift-serverless-{config.get("source_cluster_endpoint").split(".")[0]}'
else:
host = config.get("source_cluster_endpoint").split(".")[0]
port = int(config.get("source_cluster_endpoint").split(":")[-1]
.split("/")[0])
DbUser = config.get("master_username")
Expand Down
5 changes: 4 additions & 1 deletion core/replay/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def main():
# setting application name for tracking
application = "WorkloadReplicator-Replay"

host = config.get("target_cluster_endpoint").split(".")[0]
if is_serverless_endpoint:
host = f'redshift-serverless-{config.get("target_cluster_endpoint").split(".")[0]}'
else:
host = config.get("target_cluster_endpoint").split(".")[0]
port = int(config.get("target_cluster_endpoint").split(":")[-1].split("/")[0])
DbUser = config.get("master_username")
DbName = config.get("target_cluster_endpoint").split("/")[-1]
Expand Down

0 comments on commit b68fe18

Please sign in to comment.