Skip to content

Commit 87c45a8

Browse files
authored
clean up dag to clean jobset (GoogleCloudPlatform#753)
1 parent 22f515f commit 87c45a8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

dags/map_reproducibility/utils/common_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,13 @@ def get_nemo_metrics_cmds(
789789

790790
def cleanup_all_runs_cmds(cluster, cluster_region, prefix="cml-"):
791791
cleanup_cmds = (
792-
f"echo 'Getting credentials for cluster {cluster}...' && gcloud container clusters get-credentials {cluster} --region {cluster_region} --project {PROJECT} ",
793-
f"echo 'Uninstalling jobs with prefix {prefix}...' && JOBS=$(kubectl get job -n default | grep \"^{prefix}\" | awk '{{print $1}}') && if [ -n \"$JOBS\" ]; then echo \"$JOBS\" | xargs -L1 helm uninstall -n default; else echo 'No matching jobs found'; fi",
792+
f"echo 'Getting credentials for cluster {cluster}...' && gcloud container clusters get-credentials {cluster} --region {cluster_region} --project {PROJECT}",
793+
f"echo 'Uninstalling jobs with prefix {prefix}...' && "
794+
f"JOBS=$(kubectl get job -n default | grep '^{prefix}' | awk '{{print $1}}' | sed 's/-workload-0$//' | sort -u) && "
795+
f'if [ -n "$JOBS" ]; then '
796+
f'echo "$JOBS" | xargs -L1 helm uninstall -n default || true && '
797+
f'echo "$JOBS" | xargs -L1 kubectl delete job -n default || true; '
798+
f"else echo 'No matching jobs found'; fi",
794799
)
795800
return cleanup_cmds
796801

0 commit comments

Comments
 (0)