From b686ac132f639b495723310dc0488c73007fab67 Mon Sep 17 00:00:00 2001 From: vitya Date: Mon, 8 Jun 2026 13:59:10 +0300 Subject: [PATCH] fix(decommission): smoke :8091 via curl --noproxy; idempotent F2 The F3 smoke false-failed: system VPN proxy swallows Invoke-WebRequest to localhost (wiki bug #7), returning empty -> gate aborted before E/M. Verified out-of-band: :8091 -> HTTP 200 (real stostayer.old page), so the repoint actually succeeded. Switched smoke to curl.exe --noproxy. Made F2 idempotent (only repoint if still localhost) so re-runs don't clobber the original localhost backup. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../finish-elevated.ps1 | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/decommission-windows-recovery-host/finish-elevated.ps1 b/scripts/decommission-windows-recovery-host/finish-elevated.ps1 index 08fc1a4..66c5373 100644 --- a/scripts/decommission-windows-recovery-host/finish-elevated.ps1 +++ b/scripts/decommission-windows-recovery-host/finish-elevated.ps1 @@ -31,24 +31,27 @@ $cn = New-Object System.Data.SqlClient.SqlConnection $verify; $cn.Open() $c = $cn.CreateCommand(); $c.CommandText = "SELECT DB_NAME()"; $db = $c.ExecuteScalar(); $cn.Close() Write-Host " verify snolla->VDS stostayer OK (db=$db)" -ForegroundColor Green -# ---------- F2: repoint web.config ---------- +# ---------- F2: repoint web.config (idempotent) ---------- Write-Host "`n=== F2. repoint stostayer.old web.config ===" -ForegroundColor Cyan -Copy-Item $wcPath "$wcPath.bak-pre-vds-$(Get-Date -Format yyyyMMdd)" -Force -$xml = [xml](Get-Content $wcPath) -$node = $xml.configuration.connectionStrings.add | Where-Object { $_.name -eq 'MoreThenCmsEntities' } -$new = ($node.connectionString -replace '(?i)Data Source=localhost(,1433)?','Data Source=mssql.kzntsv.site,1433') -if ($new -notmatch 'TrustServerCertificate') { $new = $new.TrimEnd(';') + ';TrustServerCertificate=True' } -$node.connectionString = $new -$xml.Save($wcPath) -Write-Host " web.config -> mssql.kzntsv.site (backup alongside)" -ForegroundColor Green +if ($src -match '(?i)Data Source=localhost') { + Copy-Item $wcPath "$wcPath.bak-pre-vds-$(Get-Date -Format yyyyMMdd)" -Force + $xml = [xml](Get-Content $wcPath) + $node = $xml.configuration.connectionStrings.add | Where-Object { $_.name -eq 'MoreThenCmsEntities' } + $new = ($node.connectionString -replace '(?i)Data Source=localhost(,1433)?','Data Source=mssql.kzntsv.site,1433') + if ($new -notmatch 'TrustServerCertificate') { $new = $new.TrimEnd(';') + ';TrustServerCertificate=True' } + $node.connectionString = $new + $xml.Save($wcPath) + Write-Host " web.config -> mssql.kzntsv.site (backup alongside)" -ForegroundColor Green +} else { Write-Host " already pointed at VDS - skip (original backup preserved)" -ForegroundColor Green } -# ---------- F3: restart pool + smoke ---------- +# ---------- F3: restart pool + smoke (proxy-bypassed) ---------- Write-Host "`n=== F3. restart pool stostayer.old + smoke :8091 ===" -ForegroundColor Cyan Restart-WebAppPool -Name 'stostayer.old' Start-Sleep -Seconds 5 -$code = try { (Invoke-WebRequest "http://localhost:8091/" -UseBasicParsing -TimeoutSec 30).StatusCode } catch { $_.Exception.Response.StatusCode.value__ } +# system VPN proxy swallows localhost (wiki bug #7) -> curl.exe --noproxy bypasses it +$code = (& curl.exe -s -o NUL -w "%{http_code}" --noproxy "*" --max-time 30 http://localhost:8091/) Write-Host " :8091 -> HTTP $code" -if ((-not $code) -or ($code -ge 500)) { +if ((-not ($code -match '^\d+$')) -or ([int]$code -eq 0) -or ([int]$code -ge 500)) { Write-Error "stostayer.old returned '$code' - repoint FAILED. Leaving MSSQL untouched. Rollback: restore web.config.bak-pre-vds-*." return }