fix(telemetry): recover worker agent and Tailscale transport automatically

This commit is contained in:
DCCONSTRUCTIONS
2026-09-25 23:24:27 +03:00
parent bd5873ef34
commit f3640026cf
11 changed files with 755 additions and 4 deletions
@@ -33,6 +33,10 @@ foreach ($name in @(
Set-Item -Path "Env:$name" -Value ([string]$value)
}
$recoveryInstaller = Join-Path $PSScriptRoot 'Install-NdcMissionCoreTelemetryRecovery.ps1'
if ($payload.MISSIONCORE_MQTT_HOST -eq '127.0.0.1' -and -not (Test-Path $recoveryInstaller -PathType Leaf)) {
throw 'Telemetry recovery installer missing from bundle'
}
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
throw "Service '$serviceName' already exists; refusing an implicit replacement"
}
@@ -137,6 +141,10 @@ try {
if ($LASTEXITCODE -ne 0) {
throw "Failed to enable Telegraf recovery for non-crash failures"
}
$recoveryTask = $null
if ($payload.MISSIONCORE_MQTT_HOST -eq '127.0.0.1') {
$recoveryTask = & $recoveryInstaller -ExpectedNodeId $env:COMPUTERNAME -Action Apply | ConvertFrom-Json
}
Start-Service -Name $serviceName
$service = Get-Service -Name $serviceName
$service.WaitForStatus([ServiceProcess.ServiceControllerStatus]::Running, [TimeSpan]::FromSeconds(20))
@@ -150,6 +158,7 @@ try {
Status = $service.Status.ToString()
StartType = $service.StartType.ToString()
RecoveryConfigured = $true
RecoveryTask = $recoveryTask
Configuration = $configurationPath
PipelineCollector = $collectorPath
PipelineJournal = $PipelineJournal