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

Multiple fixes for STS token refresh #2115

Merged
merged 7 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove extra logs
phoebusm committed Jan 31, 2025
commit 71ff5b66db5a57b78cac8f486d555e943813754b
4 changes: 2 additions & 2 deletions build_tooling/parallel_test.sh
Original file line number Diff line number Diff line change
@@ -19,13 +19,13 @@ cd $PARALLEL_TEST_ROOT
export ARCTICDB_RAND_SEED=$RANDOM

if [ -z "$ARCTICDB_PYTEST_ARGS" ]; then
$catch python -m pytest -vs --timeout=3600 $PYTEST_XDIST_MODE -v \
$catch python -m pytest --timeout=3600 $PYTEST_XDIST_MODE -v \
--log-file="$TEST_OUTPUT_DIR/pytest-logger.$group.log" \
--junitxml="$TEST_OUTPUT_DIR/pytest.$group.xml" \
--basetemp="$PARALLEL_TEST_ROOT/temp-pytest-output" \
"$@" 2>&1 | sed -r "s#^(tests/.*/([^/]+\.py))?#\2#"
else
$catch python -m pytest -vs --timeout=3600 $PYTEST_XDIST_MODE -v \
$catch python -m pytest --timeout=3600 $PYTEST_XDIST_MODE -v \
--log-file="$TEST_OUTPUT_DIR/pytest-logger.$group.log" \
--junitxml="$TEST_OUTPUT_DIR/pytest.$group.xml" \
--basetemp="$PARALLEL_TEST_ROOT/temp-pytest-output" \
18 changes: 7 additions & 11 deletions python/arcticdb/storage_fixtures/s3.py
Original file line number Diff line number Diff line change
@@ -266,16 +266,15 @@ def real_s3_sts_from_environment_variables(user_name: str,
# Create IAM user
try:
iam_client.create_user(UserName=user_name)
logger.info(f"User created successfully: {user_name}")
logger.info(f"User created successfully.")
except iam_client.exceptions.EntityAlreadyExistsException:
logger.warning(f"User already exists: {user_name}")
logger.warning(f"User already exists.")
except Exception as e:
logger.error(f"Error creating user: {e}")
raise e
out.sts_test_key = Key(id=None, secret=None, user_name=user_name)

account_id = boto3.client("sts", aws_access_key_id=out.default_key.id, aws_secret_access_key=out.default_key.secret).get_caller_identity().get("Account")
logger.info(f"Account id: {account_id}")
# Create IAM role
assume_role_policy_document = {
"Version": "2012-10-17",
@@ -297,10 +296,10 @@ def real_s3_sts_from_environment_variables(user_name: str,
)
out.aws_role_arn = role_response["Role"]["Arn"]
out.aws_role = role_name
logger.info(f"Role created successfully. {role_name}")
logger.info("Role created successfully.")
except iam_client.exceptions.EntityAlreadyExistsException:
out.aws_role_arn = f"arn:aws:iam::{account_id}:role/{role_name}"
logger.warn(f"Role already exists: {role_name}")
logger.warn("Role already exists.")
except Exception as e:
logger.error(f"Error creating role: {e}")
raise e
@@ -328,23 +327,21 @@ def real_s3_sts_from_environment_variables(user_name: str,
PolicyDocument=json.dumps(s3_access_policy_document)
)
out.aws_policy_name = policy_response["Policy"]["Arn"]
logger.info(f"Policy created successfully. {policy_name}")
logger.info("Policy created successfully.")
except iam_client.exceptions.EntityAlreadyExistsException:
out.aws_policy_name = f"arn:aws:iam::{account_id}:policy/{policy_name}"
logger.warn(f"Policy already exists: {policy_name}")
logger.warn("Policy already exists.")
except Exception as e:
logger.error(f"Error creating policy: {e}")
raise e

# Attach the policy to the role
try:
response = iam_client.attach_role_policy(
iam_client.attach_role_policy(
RoleName=role_name,
PolicyArn=out.aws_policy_name
)
logger.info("Policy attached to role successfully.")
logger.info(f"Policy arn: {out.aws_policy_name}.")
logger.info(f"RESPONSE: {response}.")
except Exception as e:
logger.error(f"Error attaching policy to role: {e}")
raise e
@@ -376,7 +373,6 @@ def real_s3_sts_from_environment_variables(user_name: str,

try:
access_key_response = iam_client.create_access_key(UserName=user_name)
logger.info(f"Response access key: {access_key_response}")
out.sts_test_key.id = access_key_response["AccessKey"]["AccessKeyId"]
out.sts_test_key.secret = access_key_response["AccessKey"]["SecretAccessKey"]
logger.info("Access key created successfully.")

Unchanged files with check annotations Beta