fix: end D601 gateway tasks before apply

This commit is contained in:
Codex
2026-06-26 07:22:36 +00:00
parent 4238b23d17
commit 49100f99af
@@ -110,6 +110,7 @@ interface HwpodGatewayApplyResult {
readonly taskName: string;
readonly periodicTaskName: string;
readonly runTaskExitCode: number | null;
readonly failureDetail?: string;
readonly valuesRedacted?: boolean;
}
@@ -801,6 +802,7 @@ function applyGatewayRuntime(
taskName: profile.taskName,
periodicTaskName: profile.periodicTaskName,
runTaskExitCode: null,
failureDetail: compactResultTail(result),
valuesRedacted: true,
};
}
@@ -814,6 +816,7 @@ function applyGatewayRuntime(
taskName: profile.taskName,
periodicTaskName: profile.periodicTaskName,
runTaskExitCode: null,
failureDetail: short(result.stdout, 500),
valuesRedacted: true,
};
}
@@ -825,6 +828,7 @@ function applyGatewayRuntime(
taskName: profile.taskName,
periodicTaskName: profile.periodicTaskName,
runTaskExitCode: typeof parsed.runTaskExitCode === "number" ? parsed.runTaskExitCode : null,
failureDetail: typeof parsed.failureDetail === "string" && parsed.failureDetail.length > 0 ? short(parsed.failureDetail, 500) : undefined,
valuesRedacted: true,
};
}
@@ -864,6 +868,7 @@ function renderHwpodGatewayPlan(value: HwpodGatewayPlan): string {
["writtenFiles", value.remoteApply.writtenFiles.length],
["stoppedLegacyPids", value.remoteApply.stoppedLegacyPids.join(",") || "-"],
["runTaskExitCode", value.remoteApply.runTaskExitCode ?? "-"],
["failureDetail", value.remoteApply.failureDetail ?? "-"],
];
return [
`hwlab nodes hwpod-preinstall ${commandAction(value.command)} (${value.status})`,
@@ -1142,6 +1147,14 @@ $EnsureVbs = Join-Path $Root 'ensure-node-ws.vbs'
$RunTask = 'wscript.exe //B //Nologo "' + $RunVbs + '"'
$EnsureTask = 'wscript.exe //B //Nologo "' + $EnsureVbs + '"'
New-Item -ItemType Directory -Force -Path $Root, (Join-Path $Root 'logs'), (Join-Path $Root '.state'), (Join-Path $Root 'tools'), (Join-Path $Root 'tools\\src') | Out-Null
function EndTaskIfPresent([string]$Name) {
$task = Get-ScheduledTask -TaskName $Name -ErrorAction SilentlyContinue
if ($null -eq $task) { return }
if ([string]$task.State -eq 'Running') {
$null = schtasks /End /TN $Name 2>&1
Start-Sleep -Seconds 2
}
}
function WritePayloadFile($item) {
$target = Join-Path $Root ([string]$item.path)
$parent = Split-Path -Parent $target
@@ -1153,6 +1166,8 @@ function WritePayloadFile($item) {
return [string]$item.path
}
$stopped = @()
EndTaskIfPresent $PeriodicTaskName
EndTaskIfPresent $TaskName
$processes = @(Get-CimInstance Win32_Process -Filter "Name='bun.exe'" | Where-Object { ($_.CommandLine -match 'hwpod-node\\.ts\\s+connect') -and ($_.CommandLine -match [regex]::Escape($NodeId)) })
foreach ($proc in $processes) {
$stopped += [int]$proc.ProcessId