Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Confirm lifecycle ownership and quiescence before recovery witnesses

pulse-triage[bot]03c63c814383
diff --git a/scripts/installtests/windows_agent_lifecycle.ps1 b/scripts/installtests/windows_agent_lifecycle.ps1
index beb6d73991..b8b38b111c 100644
--- a/scripts/installtests/windows_agent_lifecycle.ps1
+++ b/scripts/installtests/windows_agent_lifecycle.ps1
@@ -62,6 +62,12 @@ function Start-LifecycleServer {
[string]$UninstallMode = 'confirm'
)
Stop-LifecycleServer
+ $existingListeners = @(Get-NetTCPConnection -ErrorAction Stop | Where-Object {
+ $_.LocalPort -eq $Port -and $_.State -eq 'Listen'
+ })
+ if ($existingListeners.Count -ne 0) {
+ throw 'Lifecycle peer port is already owned; no request or replacement is permitted.'
+ }
$version = ((& $AgentPath --version 2>$null) | Select-Object -First 1).Trim()
if ($LASTEXITCODE -ne 0) { throw "Lifecycle input version check failed (exit $LASTEXITCODE)." }
if ([string]::IsNullOrWhiteSpace($version)) {
@@ -330,14 +336,21 @@ function Invoke-SavedRemovalAcceptance {
# agent's legitimate final log writes cannot look like erased evidence.
$service = Get-LifecycleService
if ($null -eq $service) { throw 'Installed removal fixture service is missing.' }
+ $agentProcess = $null
try {
+ $serviceInfo = Get-CimInstance Win32_Service -ErrorAction Stop | Where-Object Name -eq $serviceName
+ if ($null -eq $serviceInfo -or [uint32]$serviceInfo.ProcessId -eq 0) { throw 'Fixture service process is unknown.' }
+ $agentProcess = Get-Process -Id $serviceInfo.ProcessId -ErrorAction Stop
+ if ($agentProcess.Path -ine "$env:ProgramFiles\Pulse\pulse-agent.exe") { throw 'Fixture service process identity differs.' }
$service.Stop()
$service.WaitForStatus([System.ServiceProcess.ServiceControllerStatus]::Stopped,
[TimeSpan]::FromSeconds(30))
$service.Refresh()
if ($service.Status -ne 'Stopped') { throw 'Fixture service is not confirmed stopped.' }
+ if (-not $agentProcess.WaitForExit(10000)) { throw 'Fixture process has not independently quiesced.' }
} finally {
$service.Dispose()
+ if ($null -ne $agentProcess) { $agentProcess.Dispose() }
}
$before = Get-LifecycleRecoverySnapshot
foreach ($mode in @('http-503', 'wrong-id', 'string-success', 'missing-id')) {
diff --git a/scripts/installtests/windows_saved_removal_test.go b/scripts/installtests/windows_saved_removal_test.go
index 7cb1030561..5e6703d505 100644
--- a/scripts/installtests/windows_saved_removal_test.go
+++ b/scripts/installtests/windows_saved_removal_test.go
@@ -72,6 +72,8 @@ func savedRemovalAcceptanceContract(script string) error {
`Assert-LifecycleRecoveryRetained -Before $before`,
`Assert-UninstallObservation -Mode confirm -Requests 1`,
`$observed.authenticated -ne $Requests`, `$observed.exactIdentity -ne $Requests`,
+ `$agentProcess.WaitForExit(10000)`, `$agentProcess.Path -ine`,
+ `if ($existingListeners.Count -ne 0)`,
} {
if !strings.Contains(script, gate) {
return fmt.Errorf("missing installed saved-removal proof boundary %q", gate)
@@ -122,6 +124,7 @@ func TestWindowsAgentLifecycleSavedRemovalRequiresAdverseAndCleanReadback(t *tes
`Assert-LifecycleRecoveryRetained -Before $before`,
`Assert-UninstallObservation -Mode confirm -Requests 1`,
`$observed.authenticated -ne $Requests`, `$observed.exactIdentity -ne $Requests`,
+ `$agentProcess.WaitForExit(10000)`, `if ($existingListeners.Count -ne 0)`,
`'PULSE_TOKEN_FILE'`, `'PULSE_SERVER_FINGERPRINT'`,
} {
t.Run(gate, func(t *testing.T) {