Skip to content

Commit 87cb118

Browse files
fix(evidence): track check results at runtime instead of scanning directory (#396)
Signed-off-by: Yuan Chen <yuanchen97@gmail.com> Co-authored-by: Mark Chmarny <mchmarny@users.noreply.github.com>
1 parent e44b763 commit 87cb118

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed

pkg/evidence/scripts/collect-evidence.sh

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,29 @@ wait_for_port() {
110110
return 1
111111
}
112112

113+
# Runtime results tracker — records check name and status as they execute.
114+
# Format: "name:status" entries separated by newlines.
115+
CHECK_RESULTS=""
116+
117+
# Run a collector and record its result based on the evidence file it produces.
118+
# Usage: run_check "DRA Support" "dra-support" collect_dra
119+
run_check() {
120+
local display_name="$1" file_key="$2" collector_fn="$3"
121+
local evidence_path="${EVIDENCE_DIR}/${file_key}.md"
122+
123+
"${collector_fn}"
124+
125+
if [ ! -f "${evidence_path}" ]; then
126+
CHECK_RESULTS="${CHECK_RESULTS}${display_name}:SKIP\n"
127+
elif grep -q "Result: PASS" "${evidence_path}" 2>/dev/null; then
128+
CHECK_RESULTS="${CHECK_RESULTS}${display_name}:PASS\n"
129+
elif grep -q "Result: FAIL" "${evidence_path}" 2>/dev/null; then
130+
CHECK_RESULTS="${CHECK_RESULTS}${display_name}:FAIL\n"
131+
else
132+
CHECK_RESULTS="${CHECK_RESULTS}${display_name}:UNKNOWN\n"
133+
fi
134+
}
135+
113136
# Clean up a test namespace properly: pods → resourceclaims → namespace
114137
# This order prevents stale DRA kubelet checkpoint issues caused by
115138
# orphaned ResourceClaims with delete-protection finalizers.
@@ -1438,38 +1461,38 @@ main() {
14381461

14391462
case "${SECTION}" in
14401463
dra)
1441-
collect_dra
1464+
run_check "DRA Support" "dra-support" collect_dra
14421465
;;
14431466
gang)
1444-
collect_gang
1467+
run_check "Gang Scheduling" "gang-scheduling" collect_gang
14451468
;;
14461469
secure)
1447-
collect_secure
1470+
run_check "Secure Accelerator Access" "secure-accelerator-access" collect_secure
14481471
;;
14491472
metrics)
1450-
collect_metrics
1473+
run_check "Accelerator Metrics" "accelerator-metrics" collect_metrics
14511474
;;
14521475
gateway)
1453-
collect_gateway
1476+
run_check "Inference Gateway" "inference-gateway" collect_gateway
14541477
;;
14551478
operator)
1456-
collect_operator
1479+
run_check "Robust AI Operator" "robust-operator" collect_operator
14571480
;;
14581481
hpa)
1459-
collect_hpa
1482+
run_check "Pod Autoscaling (HPA)" "pod-autoscaling" collect_hpa
14601483
;;
14611484
cluster-autoscaling)
1462-
collect_cluster_autoscaling
1485+
run_check "Cluster Autoscaling" "cluster-autoscaling" collect_cluster_autoscaling
14631486
;;
14641487
all)
1465-
collect_dra
1466-
collect_gang
1467-
collect_secure
1468-
collect_metrics
1469-
collect_gateway
1470-
collect_operator
1471-
collect_hpa
1472-
collect_cluster_autoscaling
1488+
run_check "DRA Support" "dra-support" collect_dra
1489+
run_check "Gang Scheduling" "gang-scheduling" collect_gang
1490+
run_check "Secure Accelerator Access" "secure-accelerator-access" collect_secure
1491+
run_check "Accelerator Metrics" "accelerator-metrics" collect_metrics
1492+
run_check "Inference Gateway" "inference-gateway" collect_gateway
1493+
run_check "Robust AI Operator" "robust-operator" collect_operator
1494+
run_check "Pod Autoscaling (HPA)" "pod-autoscaling" collect_hpa
1495+
run_check "Cluster Autoscaling" "cluster-autoscaling" collect_cluster_autoscaling
14731496
;;
14741497
*)
14751498
log_error "Unknown section: ${SECTION}"
@@ -1496,36 +1519,20 @@ main() {
14961519
echo " OS: ${CLUSTER_OS_IMAGE}"
14971520
echo " Evidence: ${EVIDENCE_DIR}/"
14981521
echo ""
1499-
local checks=(
1500-
"dra-support:DRA Support"
1501-
"gang-scheduling:Gang Scheduling"
1502-
"secure-accelerator-access:Secure Accelerator Access"
1503-
"accelerator-metrics:Accelerator Metrics"
1504-
"inference-gateway:Inference Gateway"
1505-
"robust-operator:Robust AI Operator"
1506-
"pod-autoscaling:Pod Autoscaling (HPA)"
1507-
"cluster-autoscaling:Cluster Autoscaling"
1508-
)
15091522
local passed=0 failed=0 skipped=0
15101523
printf " %-30s %s\n" "Check" "Status"
15111524
printf " %-30s %s\n" "-----" "------"
1512-
for entry in "${checks[@]}"; do
1513-
local file="${entry%%:*}"
1514-
local name="${entry#*:}"
1515-
local evidence_path="${EVIDENCE_DIR}/${file}.md"
1516-
if [ ! -f "${evidence_path}" ]; then
1517-
printf " %-30s %s\n" "${name}" "SKIP"
1518-
skipped=$((skipped + 1))
1519-
elif grep -q "Result: PASS" "${evidence_path}" 2>/dev/null; then
1520-
printf " %-30s %s\n" "${name}" "PASS"
1521-
passed=$((passed + 1))
1522-
elif grep -q "Result: FAIL" "${evidence_path}" 2>/dev/null; then
1523-
printf " %-30s %s\n" "${name}" "FAIL"
1524-
failed=$((failed + 1))
1525-
else
1526-
printf " %-30s %s\n" "${name}" "UNKNOWN"
1527-
fi
1528-
done
1525+
while IFS= read -r line; do
1526+
[ -z "${line}" ] && continue
1527+
local name="${line%%:*}"
1528+
local status="${line#*:}"
1529+
printf " %-30s %s\n" "${name}" "${status}"
1530+
case "${status}" in
1531+
PASS*) passed=$((passed + 1)) ;;
1532+
FAIL*) failed=$((failed + 1)) ;;
1533+
SKIP) skipped=$((skipped + 1)) ;;
1534+
esac
1535+
done < <(printf '%b' "${CHECK_RESULTS}")
15291536
echo ""
15301537
echo " Total: $((passed + failed + skipped)) | Passed: ${passed} | Failed: ${failed} | Skipped: ${skipped}"
15311538
echo ""

0 commit comments

Comments
 (0)