@@ -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
800799def 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+
10791101def get_scheduled_time (hardware : str , model : str , framework : str ):
10801102 """
10811103 Returns a cron expression for the DAG schedule based on
0 commit comments