-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add readiness checks before running ocp-virt-validation-checkup #83157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,11 +2,41 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "=== Waiting for ODF StorageClass ${STORAGE_CLASS} ===" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COUNTER=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while [ $COUNTER -lt 300 ]; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if oc get storageclass "${STORAGE_CLASS}" &>/dev/null; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "StorageClass ${STORAGE_CLASS} found" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sleep 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COUNTER=$((COUNTER + 10)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Waiting ${COUNTER}s for StorageClass ${STORAGE_CLASS}..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "=== Setting ODF StorageClass as default ===" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| oc patch storageclass "${STORAGE_CLASS}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "StorageClass ${STORAGE_CLASS} set as default" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "=== Waiting for HCO CLI download route ===" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CLI_ROUTE=$(oc get route hyperconverged-cluster-cli-download -n "${TARGET_NAMESPACE}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o jsonpath='{.status.ingress[0].host}' 2>/dev/null || echo "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -n "${CLI_ROUTE}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COUNTER=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while [ $COUNTER -lt 120 ]; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if curl -sk -o /dev/null -w '%{http_code}' "https://${CLI_ROUTE}/" 2>/dev/null | grep -qE '^(200|301|302)'; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "HCO CLI download route is ready" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sleep 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COUNTER=$((COUNTER + 10)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Waiting ${COUNTER}s for HCO CLI route to respond..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "WARNING: HCO CLI download route not found, skipping readiness check" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Fail closed when the HCO CLI download route is not ready. After Track an explicit Proposed fix COUNTER=0
+ ROUTE_READY=false
while [ $COUNTER -lt 120 ]; do
if curl -sk -o /dev/null -w '%{http_code}' "https://${CLI_ROUTE}/" 2>/dev/null | grep -qE '^(200|301|302)'; then
+ ROUTE_READY=true
echo "HCO CLI download route is ready"
break
@@
echo "Waiting ${COUNTER}s for HCO CLI route to respond..."
done
+ if [[ "${ROUTE_READY}" != true ]]; then
+ echo "ERROR: HCO CLI download route did not become ready within 120s"
+ exit 1
+ fi📝 Committable suggestion
Suggested change
🧰 Tools🪛 ast-grep (0.45.0)[warning] 27-27: curl is invoked with -k/--insecure, which disables TLS certificate verification and exposes the connection to man-in-the-middle attacks. Remove the insecure flag and let curl validate the server certificate; if you need to trust a private CA, pin it with --cacert instead. (curl-insecure-tls-bash) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "=== Discovering validation image from CNV CSV ===" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CSV_NAME=$(oc get csv -n "${TARGET_NAMESPACE}" -o json | \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jq -r '.items[] | select(.metadata.name | startswith("kubevirt-hyperconverged")).metadata.name') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/release
Length of output: 155
🏁 Script executed:
Repository: openshift/release
Length of output: 11763
🏁 Script executed:
Repository: openshift/release
Length of output: 190
🏁 Script executed:
Repository: openshift/release
Length of output: 267
🏁 Script executed:
Repository: openshift/release
Length of output: 268
🌐 Web query:
Official curl documentation --max-time default zero --connect-timeout timeout💡 Result:
In curl, the --max-time option has no default timeout; it effectively defaults to zero, meaning there is no time limit on the operation [1]. When --max-time is set (or left at its default of zero), curl will allow the operation to continue indefinitely until completion or until another network-related error occurs [1]. Regarding --connect-timeout, this option limits only the connection phase, which includes DNS lookup and TCP, TLS, or QUIC handshakes [2][3]. If curl does not successfully connect within the time specified by --connect-timeout, it will exit with a timeout error (exit code 28) [3][4]. There is no default "timeout" value for --connect-timeout that forces a connection to fail; if the option is not used, curl relies on the operating system's default connection timeout [1][5]. Both options accept decimal values for sub-second precision (e.g., --max-time 0.5 or --connect-timeout 2.781) [1][5][4].
Citations:
Bound each route probe.
The retry counter advances only after
curlreturns. Without a default operation timeout, a stalled DNS lookup, connection, TLS handshake, or response can exceed the intended 120-second limit. Add per-request--connect-timeoutand--max-timevalues, such as--connect-timeout 3 --max-time 5.🤖 Prompt for AI Agents