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

Add retries for get cluster credentials API call and remove unused variables #107

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 6 additions & 8 deletions common/aws_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import logging
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError
import asyncio
import functools
Expand Down Expand Up @@ -34,22 +35,19 @@ def redshift_describe_logging_status(source_cluster_endpoint):


def redshift_get_cluster_credentials(
region,
user,
database_name,
cluster_id,
duration=900,
auto_create=False,
additional_client_args={},
region, user, database_name, cluster_id, duration=900, auto_create=False, additional_args={}
):
rs_client = boto3.client("redshift", region, **additional_client_args)
# see https://boto3.amazonaws.com/v1/documentation/api/latest/guide/retries.html#standard-retry-mode
config = Config(retries={"max_attempts": 10, "mode": "standard"})
rs_client = boto3.client("redshift", region, config=config)
try:
response = rs_client.get_cluster_credentials(
DbUser=user,
DbName=database_name,
ClusterIdentifier=cluster_id,
DurationSeconds=duration,
AutoCreate=auto_create,
**additional_args,
)
except Exception as e:
if e == rs_client.exceptions.ClusterNotFoundFault:
Expand Down
7 changes: 2 additions & 5 deletions core/replay/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,8 @@ def correlate_transactions_with_connections(self, replay_id):
total_connections,
)

def get_connection_credentials(
self, username, database=None, max_attempts=10, skip_cache=False
):
def get_connection_credentials(self, username, database=None, skip_cache=False):
credentials_timeout_sec = 3600
retry_delay_sec = 10

# how long to cache credentials per user
cache_timeout_sec = 1800
Expand Down Expand Up @@ -177,7 +174,7 @@ def get_connection_credentials(
cluster_id=cluster_id,
duration=credentials_timeout_sec,
auto_create=False,
additional_client_args=additional_args,
additional_args=additional_args,
)

if response is None:
Expand Down