-
Notifications
You must be signed in to change notification settings - Fork 7.8k
[release] Add Azure VM launcher release test. #57921
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
Changes from all commits
094e1d3
e9d8e43
30f5c6b
0d549dc
b66fbdd
be23476
cb049d0
7496780
de65a24
e42a526
ea585d2
bdf70dc
ba07984
022ec07
71721ff
df30490
c7d0c0a
e29c97b
2ec4cb6
4c4694e
13f9ca8
d83b8e3
34af4ad
32c8d65
1ab650a
4b9145f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # This test launches an Azure VM cluster from an AWS instance. | ||
| # The test script runs on AWS while the actual cluster is created in Azure. | ||
| cloud_id: {{env["ANYSCALE_CLOUD_ID"]}} | ||
| region: us-west-2 | ||
|
|
||
| head_node_type: | ||
| name: head_node | ||
| instance_type: t3.large | ||
|
|
||
| worker_node_types: | ||
| - name: worker_node | ||
| instance_type: t3.large | ||
| min_workers: 0 | ||
| max_workers: 0 | ||
| use_spot: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| <cluster_configuration_file_path> | ||
| """ | ||
| import argparse | ||
| import json | ||
| import os | ||
| import re | ||
| import subprocess | ||
|
|
@@ -143,6 +144,51 @@ def override_docker_image(config_yaml, docker_image): | |
| config_yaml["docker"] = docker_config | ||
|
|
||
|
|
||
| def azure_authenticate(): | ||
| """Get Azure service principal credentials from AWS Secrets Manager and authenticate.""" | ||
| print("======================================") | ||
| print("Getting Azure credentials from AWS Secrets Manager...") | ||
|
|
||
| # Initialize AWS Secrets Manager client | ||
| secrets_client = boto3.client("secretsmanager", region_name="us-west-2") | ||
|
|
||
| # Get service principal credentials | ||
| secret_response = secrets_client.get_secret_value( | ||
| SecretId="azure-service-principal-oss-release" | ||
| ) | ||
| secret = secret_response["SecretString"] | ||
|
|
||
| client_id = json.loads(secret)["client_id"] | ||
| tenant_id = json.loads(secret)["tenant_id"] | ||
|
|
||
| # Get certificate | ||
| cert_response = secrets_client.get_secret_value( | ||
| SecretId="azure-service-principal-certificate" | ||
| ) | ||
| cert = cert_response["SecretString"] | ||
|
|
||
| # Write certificate to temp file | ||
| tmp_dir = tempfile.mkdtemp() | ||
| cert_path = os.path.join(tmp_dir, "azure_cert.pem") | ||
| with open(cert_path, "w") as f: | ||
| f.write(cert) | ||
|
|
||
| # Login to Azure | ||
| subprocess.check_call( | ||
| [ | ||
| "az", | ||
| "login", | ||
| "--service-principal", | ||
| "--username", | ||
| client_id, | ||
| "--certificate", | ||
| cert_path, | ||
| "--tenant", | ||
| tenant_id, | ||
| ] | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Azure Auth Fails Without AWS CredentialsThe azure_authenticate() function is called unconditionally for all Azure provider types, but it requires AWS credentials to access AWS Secrets Manager. This will fail when users try to run the script locally without AWS credentials, making the script difficult to use outside of CI. According to the PR discussion, this makes it "difficult to run the script from as someone who doesn't have access to the AWS bucket with the secrets in there." The authentication logic should be moved to a separate script or made optional to allow local development and testing. |
||
|
|
||
|
|
||
| def download_ssh_key_aws(): | ||
| """Download the ssh key from the S3 bucket to the local machine.""" | ||
| print("======================================") | ||
|
|
@@ -208,10 +254,13 @@ def cleanup_cluster(config_yaml, cluster_config): | |
| num_tries = 3 | ||
| for i in range(num_tries): | ||
| try: | ||
| env = os.environ.copy() | ||
| env.pop("PYTHONPATH", None) | ||
| subprocess.run( | ||
| ["ray", "down", "-v", "-y", str(cluster_config)], | ||
| check=True, | ||
| capture_output=True, | ||
| env=env, | ||
| ) | ||
| cleanup_security_groups(config_yaml) | ||
| # Final success | ||
|
|
@@ -321,7 +370,11 @@ def cleanup_security_groups(config): | |
|
|
||
|
|
||
| def run_ray_commands( | ||
| config_yaml, cluster_config, retries, no_config_cache, num_expected_nodes=1 | ||
| config_yaml, | ||
| cluster_config, | ||
| retries, | ||
| no_config_cache, | ||
| num_expected_nodes=1, | ||
| ): | ||
| """ | ||
| Run the necessary Ray commands to start a cluster, verify Ray is running, and clean | ||
|
|
@@ -333,18 +386,19 @@ def run_ray_commands( | |
| no_config_cache: Whether to pass the --no-config-cache flag to the ray CLI | ||
| commands. | ||
| """ | ||
|
|
||
| provider_type = config_yaml.get("provider", {}).get("type") | ||
| if provider_type == "azure": | ||
| azure_authenticate() | ||
|
marosset marked this conversation as resolved.
|
||
| print("======================================") | ||
| print("Starting new cluster...") | ||
| cmd = ["ray", "up", "-v", "-y"] | ||
| if no_config_cache: | ||
| cmd.append("--no-config-cache") | ||
| cmd.append(str(cluster_config)) | ||
|
|
||
| print(" ".join(cmd)) | ||
|
|
||
| env = os.environ.copy() | ||
| env.pop("PYTHONPATH", None) | ||
| try: | ||
| subprocess.run(cmd, check=True, capture_output=True) | ||
| subprocess.run(cmd, check=True, capture_output=True, env=env) | ||
| except subprocess.CalledProcessError as e: | ||
| print(e.output) | ||
| # print stdout and stderr | ||
|
|
@@ -371,7 +425,7 @@ def run_ray_commands( | |
| ] | ||
| if no_config_cache: | ||
| cmd.append("--no-config-cache") | ||
| subprocess.run(cmd, check=True) | ||
| subprocess.run(cmd, check=True, env=env) | ||
| success = True | ||
| break | ||
| except subprocess.CalledProcessError: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # This script is used to build an extra layer to run release tests on Azure. | ||
|
|
||
| set -exo pipefail | ||
|
|
||
| pip3 install azure-cli-core==2.21.0 azure-core azure-identity azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-common msrest msrestazure | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use depset for this? I thought many of the deps are already installed in the image? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3476,6 +3476,27 @@ | |
| prepare: bash prepare.sh | ||
| script: python run_gcs_ft_on_k8s.py | ||
|
|
||
| - name: azure_cluster_launcher | ||
| group: cluster-launcher-test | ||
| working_dir: ../python/ray/autoscaler/ | ||
| frequency: nightly | ||
| team: clusters | ||
| cluster: | ||
| byod: | ||
| post_build_script: byod_azure_cluster_launcher.sh | ||
| cluster_compute: azure/tests/azure_compute.yaml | ||
| run: | ||
| timeout: 2400 | ||
| script: bash release/azure_docker_login.sh && python -I launch_and_verify_cluster.py azure/tests/azure-cluster.yaml --num-expected-nodes 3 --retries 10 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| variations: | ||
| - __suffix__: v1 | ||
| run: | ||
| script: RAY_UP_enable_autoscaler_v2=0 python -I launch_and_verify_cluster.py azure/tests/azure-cluster.yaml --num-expected-nodes 3 --retries 10 | ||
| - __suffix__: v2 | ||
| run: | ||
| script: RAY_UP_enable_autoscaler_v2=1 python -I launch_and_verify_cluster.py azure/tests/azure-cluster.yaml --num-expected-nodes 3 --retries 10 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| - name: aws_cluster_launcher | ||
| group: cluster-launcher-test | ||
| working_dir: ../python/ray/autoscaler/ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Azure Tests Fail Due to Incorrect AWS Configuration
The
azure_compute.yamlfile, intended for Azure cluster launcher tests, incorrectly specifies AWS configuration. It uses AWS regionus-west-2and instance typet3.large, which causes Azure tests to fail.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khluu - maybe consider adding a comment saying this we run launch_and_verify_cluster.py from an a AWS VM but the ray cluster gets created in azure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1