Make dev validateBuild bounds check resilient
Retry and prefer LAN bounds URL to avoid transient 504 failures. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
aa6635803d
commit
ae6ffc8a08
@@ -170,21 +170,36 @@ function Get-LatestDevBackup {
|
||||
}
|
||||
|
||||
function Test-BoundsJson {
|
||||
param([string]$Url, [switch]$Insecure)
|
||||
param(
|
||||
[string]$Url,
|
||||
[switch]$Insecure,
|
||||
[int]$MaxTimeSeconds = 10,
|
||||
[int]$Retries = 3
|
||||
)
|
||||
|
||||
$curlArgs = @('-s', '-f')
|
||||
for ($attempt = 1; $attempt -le $Retries; $attempt++) {
|
||||
$curlArgs = @('-s', '-f', '--max-time', $MaxTimeSeconds)
|
||||
if ($Insecure) { $curlArgs += '-k' }
|
||||
$curlArgs += $Url
|
||||
|
||||
$body = & curl.exe @curlArgs 2>$null
|
||||
if ($LASTEXITCODE -ne 0 -or -not $body) {
|
||||
return $false
|
||||
}
|
||||
if ($LASTEXITCODE -eq 0 -and $body) {
|
||||
try {
|
||||
$json = $body | ConvertFrom-Json
|
||||
return ($null -ne $json.min_year -and $null -ne $json.max_year)
|
||||
} catch {
|
||||
return $false
|
||||
if ($null -ne $json.min_year -and $null -ne $json.max_year) {
|
||||
return $true
|
||||
}
|
||||
} catch {
|
||||
# Continue retries below.
|
||||
}
|
||||
}
|
||||
|
||||
if ($attempt -lt $Retries) {
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
||||
|
||||
# --- Load config ---
|
||||
@@ -232,12 +247,29 @@ if (Get-StepEnabled $steps 'validateBuild') {
|
||||
$code = Invoke-Npm 'prod:build'
|
||||
if ($code -ne 0) { return $code }
|
||||
|
||||
$devUrl = if ($cfg.verify.devUrl) { $cfg.verify.devUrl } else { 'https://devgallery.mysuperlab.netcraze.pro/api/bounds' }
|
||||
if (-not (Test-BoundsJson -Url $devUrl -Insecure)) {
|
||||
Write-Host "Dev API check failed: $devUrl" -ForegroundColor Red
|
||||
$devCandidates = @()
|
||||
if ($cfg.verify.lanUrl) { $devCandidates += $cfg.verify.lanUrl }
|
||||
if ($cfg.verify.devUrl -and ($devCandidates -notcontains $cfg.verify.devUrl)) { $devCandidates += $cfg.verify.devUrl }
|
||||
if (-not $devCandidates -or $devCandidates.Count -eq 0) {
|
||||
$devCandidates = @('https://devgallery.mysuperlab.netcraze.pro/api/bounds')
|
||||
}
|
||||
|
||||
$devOk = $false
|
||||
foreach ($u in $devCandidates) {
|
||||
Write-Host "Checking dev /api/bounds: $u"
|
||||
$useInsecure = $u.StartsWith('https://', [System.StringComparison]::OrdinalIgnoreCase)
|
||||
if (Test-BoundsJson -Url $u -Insecure:$useInsecure -MaxTimeSeconds 10 -Retries 3) {
|
||||
Write-Host "Dev API OK: $u"
|
||||
$devOk = $true
|
||||
break
|
||||
}
|
||||
Write-Host "Dev API check failed for: $u" -ForegroundColor DarkYellow
|
||||
}
|
||||
|
||||
if (-not $devOk) {
|
||||
Write-Host "Dev API check failed on all URLs." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
Write-Host "Dev API OK: $devUrl"
|
||||
return 0
|
||||
}
|
||||
if (-not $ok) { Write-ReleaseBanner -Success $false -FailedAt $FailedStep; exit 1 }
|
||||
|
||||
Reference in New Issue
Block a user