Skip to content
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
1 change: 0 additions & 1 deletion .buildkite/data.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ steps:
- skip-on-premerge
instance_type: medium
commands:
- pip install -U boto3==1.28.70 awscli==1.29.70
- $(python ci/env/setup_credentials.py)
- bazel run //ci/ray_ci:test_in_docker -- //python/ray/data/... data
--build-name datalbuild
Expand Down
2 changes: 0 additions & 2 deletions .buildkite/ml.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ steps:
- oss
instance_type: medium
commands:
- pip install -U boto3==1.28.70 awscli==1.29.70
- $(python ci/env/setup_credentials.py)
- bazel run //ci/ray_ci:test_in_docker -- //python/ray/train/... ml
--parallelism-per-worker 3
Expand Down Expand Up @@ -295,7 +294,6 @@ steps:
- oss
instance_type: medium
commands:
- pip install -U boto3==1.28.70 awscli==1.29.70
- $(python ci/env/setup_credentials.py)
- bazel run //ci/ray_ci:test_in_docker -- //... ml --run-flaky-tests
--parallelism-per-worker 3
Expand Down
25 changes: 17 additions & 8 deletions ci/env/setup_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,30 @@
export COMET_API_KEY=efgh
"""
import json
import subprocess
import sys

import boto3

AWS_AIR_SECRETS_ARN = (
"arn:aws:secretsmanager:us-west-2:029272617770:secret:"
"oss-ci/ray-air-test-secrets20221014164754935800000002-UONblX"
)


def get_ray_air_secrets(client):
raw_string = client.get_secret_value(SecretId=AWS_AIR_SECRETS_ARN)["SecretString"]
return json.loads(raw_string)
def get_ray_air_secrets():
output = subprocess.check_output(
[
"aws",
"secretsmanager",
"get-secret-value",
"--region",
"us-west-2",
"--secret-id",
AWS_AIR_SECRETS_ARN,
]
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing AWS CLI Causes Credential Setup Failure

The setup_credentials.py script now calls the aws CLI directly, but the CI configuration removed the awscli installation. This prevents the aws command from being found, causing the credential setup to fail and impacting tests that rely on these secrets.

Additional Locations (1)

Fix in Cursor Fix in Web


parsed_output = json.loads(output)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: AWS CLI Output Parsing Error

The subprocess.check_output() call returns bytes, but json.loads() expects a string, leading to a TypeError when parsing the AWS CLI output. While json.loads() can sometimes handle bytes in newer Python versions, this is fragile and may cause unexpected failures.

Fix in Cursor Fix in Web

return json.loads(parsed_output["SecretString"])


SERVICES = {
Expand All @@ -36,10 +47,8 @@ def get_ray_air_secrets(client):


def main():

try:
client = boto3.client("secretsmanager", region_name="us-west-2")
ray_air_secrets = get_ray_air_secrets(client)
ray_air_secrets = get_ray_air_secrets()
except Exception as e:
print(f"Could not get Ray AIR secrets: {e}")
sys.exit(1)
Comment on lines 50 to 54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The exception handling here is very broad, catching Exception. While the previous code did this as well, the new implementation using subprocess can raise different types of exceptions like subprocess.CalledProcessError, FileNotFoundError (if aws isn't in PATH), json.JSONDecodeError, or KeyError. It would be more robust to handle these specific exceptions to provide more informative error messages and improve debuggability. Also, it's a good practice to print error messages to sys.stderr.

Suggested change
try:
client = boto3.client("secretsmanager", region_name="us-west-2")
ray_air_secrets = get_ray_air_secrets(client)
ray_air_secrets = get_ray_air_secrets()
except Exception as e:
print(f"Could not get Ray AIR secrets: {e}")
sys.exit(1)
try:
ray_air_secrets = get_ray_air_secrets()
except (subprocess.CalledProcessError, FileNotFoundError) as e:
print(f"Error executing aws-cli command: {e}", file=sys.stderr)
sys.exit(1)
except (json.JSONDecodeError, KeyError) as e:
print(f"Error parsing secrets from aws-cli output: {e}", file=sys.stderr)
sys.exit(1)

Expand Down