diff --git a/contrib/ray/test.sh b/contrib/ray/test.sh index 5d8fbf4af5..a06bc06863 100755 --- a/contrib/ray/test.sh +++ b/contrib/ray/test.sh @@ -7,39 +7,10 @@ TIMEOUT=120 # timeout in seconds SLEEP_INTERVAL=30 # interval between checks in seconds RAY_VERSION=2.23.0 -function trap_handler { - # Delete RayCluster - kubectl -n $NAMESPACE delete -f raycluster_example.yaml - - # Wait for all Ray Pods to be deleted. - start_time=$(date +%s) - while true; do - pods=$(kubectl -n $NAMESPACE get pods -o json | jq '.items | length') - if [ "$pods" -eq 0 ]; then - kill $PID - break - fi - current_time=$(date +%s) - elapsed_time=$((current_time - start_time)) - if [ "$elapsed_time" -ge "$TIMEOUT" ]; then - echo "Timeout exceeded. Exiting loop." - exit 1 - fi - sleep $SLEEP_INTERVAL - done - - # Delete KubeRay operator - kustomize build kuberay-operator/base | kubectl -n kubeflow delete -f - - -} - -trap trap_handler EXIT - kubectl label namespace $NAMESPACE istio-injection=enabled kubectl get namespaces --selector=istio-injection=enabled - # Install KubeRay operator kustomize build kuberay-operator/overlays/standalone | kubectl -n kubeflow apply --server-side -f - @@ -73,3 +44,26 @@ else echo "Test failed!" exit 1 fi + +# Delete RayCluster +kubectl -n $NAMESPACE delete -f raycluster_example.yaml + +# Wait for all Ray Pods to be deleted. +start_time=$(date +%s) +while true; do + pods=$(kubectl -n $NAMESPACE get pods -o json | jq '.items | length') + if [ "$pods" -eq 0 ]; then + kill $PID + break + fi + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + if [ "$elapsed_time" -ge "$TIMEOUT" ]; then + echo "Timeout exceeded. Exiting loop." + exit 1 + fi + sleep $SLEEP_INTERVAL +done + +# Delete KubeRay operator +kustomize build kuberay-operator/base | kubectl -n kubeflow delete -f - \ No newline at end of file