fix(reboot): bound windows99 vm discovery fallback
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m3s
CD Pipeline / build-and-deploy (push) Successful in 4m29s
CD Pipeline / post-deploy-checks (push) Successful in 1m48s
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m3s
CD Pipeline / build-and-deploy (push) Successful in 4m29s
CD Pipeline / post-deploy-checks (push) Successful in 1m48s
This commit is contained in:
@@ -20,6 +20,7 @@ POST_REBOOT_READINESS_TIMEOUT_SECONDS="${POST_REBOOT_READINESS_TIMEOUT_SECONDS:-
|
||||
PUBLIC_MAINTENANCE_READBACK_TIMEOUT_SECONDS="${PUBLIC_MAINTENANCE_READBACK_TIMEOUT_SECONDS:-8}"
|
||||
PUBLIC_MAINTENANCE_URLS="${PUBLIC_MAINTENANCE_URLS:-https://awoooi.wooo.work/api/v1/health https://awoooi.wooo.work/ https://stock.wooo.work/api/v1/system/freshness https://mo.wooo.work/health https://bitan.wooo.work/ https://www.tsenyang.com/}"
|
||||
WINDOWS99_VMWARE_FALLBACK_MAX_AGE_SECONDS="${WINDOWS99_VMWARE_FALLBACK_MAX_AGE_SECONDS:-900}"
|
||||
WINDOWS99_REQUIRED_VM_ALIASES="${WINDOWS99_REQUIRED_VM_ALIASES:-111 188 120 121 112}"
|
||||
POST_REBOOT_READINESS_FALLBACK_MAX_AGE_SECONDS="${POST_REBOOT_READINESS_FALLBACK_MAX_AGE_SECONDS:-900}"
|
||||
|
||||
mkdir -p "$TEXTFILE_DIR" "$LOG_DIR"
|
||||
@@ -323,11 +324,37 @@ if [ -f "$ROOT_DIR/scripts/reboot-recovery/windows99-management-channel-probe.py
|
||||
fi
|
||||
if [ -x "$ROOT_DIR/scripts/reboot-recovery/collect-windows99-vmware-verify.sh" ]; then
|
||||
WINDOWS99_MAX_AUTH_USERS="${WINDOWS99_MAX_AUTH_USERS:-5}" \
|
||||
WINDOWS99_REMOTE_VERIFY_TIMEOUT="${WINDOWS99_REMOTE_VERIFY_TIMEOUT:-90}" \
|
||||
bash "$ROOT_DIR/scripts/reboot-recovery/collect-windows99-vmware-verify.sh" --collect \
|
||||
>"$windows99_vmware_file" 2>"$artifact_dir/windows99-vmware-verify.err" \
|
||||
|| true
|
||||
fi
|
||||
|
||||
windows99_vmware_verify_alias_set_matches_current() {
|
||||
local file="$1"
|
||||
local alias
|
||||
local observed
|
||||
for alias in $WINDOWS99_REQUIRED_VM_ALIASES; do
|
||||
grep -Eq "^(VMX|VM_POWER) alias=${alias}[[:space:]]" "$file" || return 1
|
||||
done
|
||||
while IFS= read -r observed; do
|
||||
[ -n "$observed" ] || continue
|
||||
case " $WINDOWS99_REQUIRED_VM_ALIASES " in
|
||||
*" $observed "*) ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
done < <(awk '
|
||||
/^(VMX|VM_POWER) alias=/ {
|
||||
for (i = 1; i <= NF; i++) {
|
||||
if ($i ~ /^alias=/) {
|
||||
sub(/^alias=/, "", $i)
|
||||
print $i
|
||||
}
|
||||
}
|
||||
}
|
||||
' "$file" | sort -u)
|
||||
}
|
||||
|
||||
if ! [ -s "$windows99_vmware_file" ] || ! grep -q '^AWOOOI_WINDOWS99_VMWARE_AUTOSTART=1$' "$windows99_vmware_file"; then
|
||||
if [ -s "$windows99_vmware_file" ]; then
|
||||
cp "$windows99_vmware_file" "$artifact_dir/windows99-vmware-verify.current-failed.txt" || true
|
||||
@@ -340,6 +367,7 @@ if ! [ -s "$windows99_vmware_file" ] || ! grep -q '^AWOOOI_WINDOWS99_VMWARE_AUTO
|
||||
[ "$candidate_path" = "$windows99_vmware_file" ] && continue
|
||||
[ -s "$candidate_path" ] || continue
|
||||
grep -q '^AWOOOI_WINDOWS99_VMWARE_AUTOSTART=1$' "$candidate_path" || continue
|
||||
windows99_vmware_verify_alias_set_matches_current "$candidate_path" || continue
|
||||
candidate_epoch="${candidate_mtime%.*}"
|
||||
candidate_age="$((now_epoch - candidate_epoch))"
|
||||
[ "$candidate_age" -le "$WINDOWS99_VMWARE_FALLBACK_MAX_AGE_SECONDS" ] || continue
|
||||
|
||||
@@ -109,6 +109,9 @@ def test_exporter_projects_each_scorecard_blocker_to_textfile_metric() -> None:
|
||||
assert "windows99-vmware-verify.txt" in text
|
||||
assert "collect-windows99-vmware-verify.sh\" --collect" in text
|
||||
assert "WINDOWS99_MAX_AUTH_USERS=\"${WINDOWS99_MAX_AUTH_USERS:-5}\"" in text
|
||||
assert "WINDOWS99_REMOTE_VERIFY_TIMEOUT=\"${WINDOWS99_REMOTE_VERIFY_TIMEOUT:-90}\"" in text
|
||||
assert "WINDOWS99_REQUIRED_VM_ALIASES=\"${WINDOWS99_REQUIRED_VM_ALIASES:-111 188 120 121 112}\"" in text
|
||||
assert "windows99_vmware_verify_alias_set_matches_current" in text
|
||||
assert "AWOOOI_WINDOWS99_VMWARE_AUTOSTART=1" in text
|
||||
assert "scorecard_args+=(--windows99-vmware-file" in text
|
||||
assert "WINDOWS99_VMWARE_FALLBACK_MAX_AGE_SECONDS" in text
|
||||
|
||||
@@ -85,6 +85,7 @@ def test_reboot_p0_contract_covers_all_required_hosts_and_vmware_autostart() ->
|
||||
assert "Host120Vmx" in windows99
|
||||
assert "Host121Vmx" in windows99
|
||||
assert "Host112Vmx" in windows99
|
||||
assert "EnableRecursiveDiscovery" in windows99
|
||||
assert "D:\\Documents\\Virtual Machines" in windows99
|
||||
assert "D:\\Downloads" in windows99
|
||||
assert '[string[]]$RequiredVmAliases = @("111", "188", "120", "121", "112")' in windows99
|
||||
|
||||
@@ -9,6 +9,7 @@ param(
|
||||
[string]$Host121Vmx = "",
|
||||
[string]$Host112Vmx = "",
|
||||
[string[]]$RequiredVmAliases = @("111", "188", "120", "121", "112"),
|
||||
[switch]$EnableRecursiveDiscovery,
|
||||
[string[]]$DiscoveryRoot = @(
|
||||
"D:\Documents\Virtual Machines",
|
||||
"D:\Downloads",
|
||||
@@ -56,6 +57,10 @@ function Resolve-VmxPath {
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $EnableRecursiveDiscovery) {
|
||||
return ""
|
||||
}
|
||||
|
||||
foreach ($root in $DiscoveryRoot) {
|
||||
if (-not (Test-Path -LiteralPath $root)) {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user