@@ -9,18 +9,18 @@ cleanup_on_exit() {
99 # Use TEST_EXIT_CODE if set, otherwise use the current exit code
1010 local exit_code=${TEST_EXIT_CODE:- $? }
1111 local cleanup_ran=0
12-
12+
1313 # Only run cleanup if we've started the process (TEMP_KUBECONFIG exists)
1414 if [ -n " ${TEMP_KUBECONFIG:- } " ] && [ -f " ${TEMP_KUBECONFIG} " ]; then
1515 cleanup_ran=1
1616 echo " "
1717 echo " ============================================================================"
1818 echo " Running cleanup (test exit code: $exit_code )"
1919 echo " ============================================================================"
20-
20+
2121 # Ensure KUBECONFIG is set to temp file
2222 export KUBECONFIG=" ${TEMP_KUBECONFIG} "
23-
23+
2424 # Try to login as admin for cleanup
2525 if [ -n " ${OCP_ADMIN_USER_USERNAME:- } " ] && [ -n " ${OCP_ADMIN_USER_PASSWORD:- } " ] && [ -n " ${OCP_API_URL:- } " ]; then
2626 echo " Logging in to OpenShift with OCP_ADMIN_USER for cleanup..."
@@ -29,17 +29,17 @@ cleanup_on_exit() {
2929 --password=" $OCP_ADMIN_USER_PASSWORD " \
3030 --insecure-skip-tls-verify=true 2> /dev/null; then
3131 echo " Successfully logged in with OCP_ADMIN_USER for cleanup"
32-
32+
3333 # Cleanup RBAC Policies
3434 if [ -n " ${TEST_USER_USERNAME:- } " ]; then
3535 echo " Cleaning up RBAC policies..."
3636 RBAC_FILE=" /codeflare-sdk/images/tests/rbac-test-user-permissions.yaml"
3737 RBAC_TEMP_FILE=" /tmp/rbac-test-user-permissions-cleanup-$$ .yaml"
38-
38+
3939 if [ -f " $RBAC_FILE " ]; then
4040 ESCAPED_USERNAME=$( printf ' %s\n' " $TEST_USER_USERNAME " | sed ' s/[[\.*^$()+?{|]/\\&/g' )
4141 sed " s/TEST_USER_USERNAME_PLACEHOLDER/$ESCAPED_USERNAME /g" " $RBAC_FILE " > " $RBAC_TEMP_FILE " 2> /dev/null
42-
42+
4343 if [ -f " $RBAC_TEMP_FILE " ]; then
4444 echo " Deleting RBAC resources..."
4545 oc delete -f " $RBAC_TEMP_FILE " 2> /dev/null || {
@@ -54,11 +54,11 @@ cleanup_on_exit() {
5454 else
5555 echo " WARNING: TEST_USER_USERNAME not found, cannot cleanup RBAC"
5656 fi
57-
57+
5858 # Set Kueue Component to Removed State
5959 echo " Setting Kueue component to Removed state..."
6060 DSC_NAME=$( get_dsc_name 2> /dev/null || echo " " )
61-
61+
6262 if [ -n " $DSC_NAME " ] && [[ ! " $DSC_NAME " =~ ^ERROR ]]; then
6363 set_kueue_management_state " Removed" " $DSC_NAME " 2> /dev/null || {
6464 echo " WARNING: Failed to set Kueue to Removed state"
@@ -75,14 +75,14 @@ cleanup_on_exit() {
7575 else
7676 echo " WARNING: Admin credentials not available for cleanup"
7777 fi
78-
78+
7979 # Cleanup temporary kubeconfig
8080 rm -f " ${TEMP_KUBECONFIG} " 2> /dev/null || true
81-
81+
8282 echo " ============================================================================"
8383 echo " "
8484 fi
85-
85+
8686 # Only exit if we actually ran cleanup (to avoid double exit)
8787 if [ $cleanup_ran -eq 1 ]; then
8888 exit $exit_code
@@ -94,7 +94,7 @@ trap cleanup_on_exit EXIT
9494
9595# ============================================================================
9696# Environment Variables Setup
97- #
97+ #
9898# Required environment variables (should be set by Jenkins or --env-file):
9999# TEST_USER_USERNAME=<username>
100100# TEST_USER_PASSWORD=<password>
@@ -165,23 +165,23 @@ wait_for_dsc_ready() {
165165 local timeout=${1:- 600}
166166 local interval=10
167167 local elapsed=0
168-
168+
169169 echo " Waiting for DataScienceCluster to be in Ready state (timeout: ${timeout} s)..."
170-
170+
171171 while [ $elapsed -lt " $timeout " ]; do
172172 local phase
173173 phase=$( oc get DataScienceCluster --no-headers -o custom-columns=" :status.phase" 2> /dev/null | head -n1)
174-
174+
175175 if [ " $phase " = " Ready" ]; then
176176 echo " DataScienceCluster is in Ready state"
177177 return 0
178178 fi
179-
179+
180180 echo " DataScienceCluster phase: ${phase:- Unknown} (elapsed: ${elapsed} s)"
181181 sleep $interval
182182 elapsed=$(( elapsed + interval))
183183 done
184-
184+
185185 echo " ERROR: Timeout waiting for DataScienceCluster to be Ready (waited ${timeout} s)"
186186 return 1
187187}
@@ -191,18 +191,18 @@ wait_for_dsc_ready() {
191191set_kueue_management_state () {
192192 local state=$1
193193 local cluster_name=$2
194-
194+
195195 if [ -z " $state " ] || [ -z " $cluster_name " ]; then
196196 echo " ERROR: Invalid arguments for set_kueue_management_state"
197197 return 1
198198 fi
199-
199+
200200 echo " Setting Kueue component management state to: $state "
201201 oc patch DataScienceCluster " $cluster_name " --type ' json' -p " [{\" op\" : \" replace\" ,\" path\" : \" /spec/components/kueue/managementState\" ,\" value\" : \" $state \" }]" || {
202202 echo " ERROR: Failed to set Kueue management state to $state "
203203 return 1
204204 }
205-
205+
206206 echo " Successfully set Kueue management state to: $state "
207207 return 0
208208}
@@ -453,4 +453,3 @@ echo ""
453453
454454# Exit - the trap will handle cleanup automatically
455455exit $TEST_EXIT_CODE
456-
0 commit comments