Skip to content

Commit b0c69a4

Browse files
authored
add --dns-falg for imo-a3ultra cluster (GoogleCloudPlatform#811)
1 parent c37af46 commit b0c69a4

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

dags/map_reproducibility/utils/common_utils.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ def configure_project_and_cluster(cluster: str, cluster_region: str):
216216
set_project_command = (
217217
f"gcloud config set project {PROJECT}",
218218
"sudo chown -R airflow:airflow /home/airflow/composer_kube_config",
219-
"gcloud container clusters get-credentials "
220-
f"{cluster} --region {cluster_region}",
219+
get_credentials_command(cluster, cluster_region),
221220
)
222221
return set_project_command
223222

@@ -799,7 +798,8 @@ def get_nemo_metrics_cmds(
799798

800799
def cleanup_all_runs_cmds(cluster, cluster_region, prefix="cml-"):
801800
cleanup_cmds = (
802-
f"echo 'Getting credentials for cluster {cluster}...' && gcloud container clusters get-credentials {cluster} --region {cluster_region} --project {PROJECT}",
801+
f"echo 'Uninstalling jobs with prefix {prefix}...'",
802+
get_credentials_command(cluster, cluster_region, PROJECT),
803803
f"echo 'Uninstalling jobs with prefix {prefix}...' && "
804804
f"JOBS=$(kubectl get job -n default | grep '^{prefix}' | awk '{{print $1}}' | sed 's/-workload-0$//' | sort -u) && "
805805
f'if [ -n "$JOBS" ]; then '
@@ -1076,6 +1076,28 @@ def get_cluster(hardware: str = "a3ultra"):
10761076
return "gke-a4-sbrg1", "us-east4"
10771077

10781078

1079+
def is_dns_endpoint(cluster: str):
1080+
"""Indicate if the cluster needs dns-endpoint flag."""
1081+
if cluster == "imo-a3ultra":
1082+
return True
1083+
return False
1084+
1085+
1086+
def get_credentials_command(
1087+
cluster: str, cluster_region: str, project: None | str = None
1088+
):
1089+
"""
1090+
Returns the gcloud get-credentials command string.
1091+
Includes the --dns-endpoint flag if required.
1092+
"""
1093+
base_command = f"gcloud container clusters get-credentials {cluster} --region {cluster_region}"
1094+
if project is not None:
1095+
base_command += f" --project {project}"
1096+
if is_dns_endpoint(cluster):
1097+
return f"{base_command} --dns-endpoint"
1098+
return base_command
1099+
1100+
10791101
def get_scheduled_time(hardware: str, model: str, framework: str):
10801102
"""
10811103
Returns a cron expression for the DAG schedule based on

dags/map_reproducibility/utils/sample_workload_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
get_internal_pre_workload_job_name,
3232
get_bq_writer_path,
3333
get_cluster,
34+
get_credentials_command,
3435
calculate_maxtext_metrics,
3536
copy_bucket_cmds_maxtext,
3637
get_job_gcs_bucket_folder,
@@ -124,8 +125,7 @@ def execute_workload_commands(commands: list, cwd: str) -> Tuple[bool, list]:
124125
def sample_job_configure_project_and_cluster(cluster: str, cluster_region: str):
125126
set_project_command = (
126127
f"gcloud config set project {PROJECT}",
127-
"gcloud container clusters get-credentials "
128-
f"{cluster} --region {cluster_region}",
128+
get_credentials_command(cluster, cluster_region),
129129
)
130130
return set_project_command
131131

0 commit comments

Comments
 (0)