Skip to content

Commit 8b6a645

Browse files
rhoppclaude
andcommitted
Add retry loop for oc login with kubeadmin credentials
Add a 5-minute retry loop (30 attempts with 10-second intervals) to ensure successful login to the provisioned cluster using kubeadmin credentials. This handles cases where the cluster API is accessible but authentication may not be immediately ready. The retry loop includes proper validation via 'oc whoami' and integrates with the existing provisioning retry logic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 1775085 commit 8b6a645

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

integration-tests/pipelines/tssc-cli-e2e.yaml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,53 @@ spec:
207207
echo "Console is ready. Continuing."
208208
echo "--- Console Accessibility Check Finished ---"
209209
210-
# If we reach here, both CSR approval and console accessibility succeeded
210+
# --- OC Login Retry Loop ---
211+
echo "--- Starting OC Login Process ---"
212+
login_max_retries=30 # 5 minutes with 10-second intervals
213+
login_sleep_duration=10
214+
login_successful=false
215+
216+
for ((k=1; k<=login_max_retries; k++)); do
217+
echo "OC Login Attempt $k of $login_max_retries: Attempting to login with kubeadmin..."
218+
if oc login --insecure-skip-tls-verify=true "$api_url" -u kubeadmin -p "$kubeadminpass" 2>&1; then
219+
echo "Successfully logged in as kubeadmin on attempt $k."
220+
if oc whoami 2>&1; then
221+
echo "Confirmed login - current user: $(oc whoami)"
222+
login_successful=true
223+
break
224+
else
225+
echo "Login succeeded but 'oc whoami' failed on attempt $k."
226+
fi
227+
else
228+
oc_login_exit_code=$?
229+
echo "OC login failed on attempt $k (exit code: $oc_login_exit_code)."
230+
fi
231+
232+
if [[ "$k" -lt "$login_max_retries" ]]; then
233+
echo "Sleeping for $login_sleep_duration seconds before next login retry..."
234+
sleep "$login_sleep_duration"
235+
fi
236+
done
237+
238+
if [[ "$login_successful" == "false" ]]; then
239+
echo "Failed to login with kubeadmin after $login_max_retries attempts."
240+
if [[ "$provisioning_attempt" -lt "$provisioning_max_retries" ]]; then
241+
echo "Will retry entire provisioning process..."
242+
continue
243+
else
244+
echo "All provisioning attempts exhausted. Exiting."
245+
exit 1
246+
fi
247+
fi
248+
echo "OC login completed successfully."
249+
echo "--- OC Login Process Finished ---"
250+
251+
# If we reach here, CSR approval, console accessibility, and OC login all succeeded
211252
provisioning_successful=true
212253
echo "=== Cluster Provisioning Completed Successfully on Attempt $provisioning_attempt ==="
213254
break
214255
done
215-
256+
oc get co
216257
if [[ "$provisioning_successful" == "false" ]]; then
217258
echo "Cluster provisioning failed after $provisioning_max_retries attempts."
218259
exit 1

0 commit comments

Comments
 (0)