From 8b7ade65e639f34ff0489e0bbea65b6f1793fac6 Mon Sep 17 00:00:00 2001 From: rebuildup Date: Mon, 30 Nov 2026 14:50:54 +0900 Subject: [PATCH] =?UTF-8?q?fix(#289):=20devices=20sync=20=E3=81=AE?= =?UTF-8?q?=E5=88=B0=E9=81=94=E4=B8=8D=E8=83=BD=20failure=20=E3=82=92=20pe?= =?UTF-8?q?nding=20=E3=81=A8=E3=81=97=E3=81=A6=E8=A8=98=E9=8C=B2=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `devices.ts` の sync は各 node に check / requireSession を実行するため、1 台でも 到達不能なら全体が fail closed になる。該当 node が lab 用の別 machine で停止して いるだけで、自分の machine の configuration とは無関係なのに、毎時 converge が exit 1 になっていた (実測: device-lab-win 100.84.109.16 が timeout)。 - Windows converge (`platforms/windows-11/converge.ps1`) と POSIX converge (`scripts/converge.sh`) は、devices sync の失敗が「他 node への到達不能 / reject」を示す場合 error ではなく pending として記録する (終了コード 3)。 - 構文エラーや collision など、自分の machine に起因する失敗は error のまま。 - CI に回帰防止の check を追加。 dotfiles 側の reachability と configuration の分離は rebuildup/dotfiles で 検討する。 Co-Authored-By: Claude Code --- .github/workflows/ci.yml | 18 ++++++++++++++++++ platforms/windows-11/converge.ps1 | 14 ++++++++++++-- scripts/ci.sh | 9 +++++++++ scripts/converge.sh | 15 +++++++++++++-- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07241e15..af868820 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -338,6 +338,24 @@ jobs: fi grep -Fxq "120s|5|-C $HOME install|token=set" "$log" + # Another machine's reachability is not this machine's configuration + # state: a devices sync that fails only because a node is unreachable is + # recorded as pending, so the hourly convergence keeps reporting the + # real result. + - name: Validate the devices sync failure classification + shell: pwsh + run: | + Set-StrictMode -Version Latest + $ErrorActionPreference = 'Stop' + + $converge = Get-Content -LiteralPath ./platforms/windows-11/converge.ps1 -Raw + if (-not $converge.Contains("Add-Step 'devices-sync' 'pending'")) { + throw 'the devices sync step must record an unreachable node as pending.' + } + if (-not $converge.Contains('unavailable or rejected')) { + throw 'the devices sync step must recognise the reachability failure.' + } + - name: Validate global lock adoption run: | set -euo pipefail diff --git a/platforms/windows-11/converge.ps1 b/platforms/windows-11/converge.ps1 index 0f5bb5d9..e093c178 100644 --- a/platforms/windows-11/converge.ps1 +++ b/platforms/windows-11/converge.ps1 @@ -335,10 +335,11 @@ function Sync-Devices { $previousPath = $env:PATH $env:PATH = (Join-Path $env:LOCALAPPDATA 'mise\shims') + ';' + $env:PATH $code = 0 + $devicesOut = @() try { Push-Location $DotfilesDir try { - & $bunPath $devicesScript sync *>> $script:LogFile + $devicesOut = @(& $bunPath $devicesScript sync *>&1 | ForEach-Object { [string]$_ }) $code = $LASTEXITCODE } finally { Pop-Location @@ -346,9 +347,18 @@ function Sync-Devices { } finally { $env:PATH = $previousPath } + $devicesOut | ForEach-Object { Write-Log $_ } if ($code -eq 0) { Add-Step 'devices-sync' 'ok' 'devices sync converged' - } else { + } + elseif (($devicesOut -join "`n") -match 'unavailable or rejected') { + # Another machine's reachability is not this machine's configuration + # state: the local definitions were applied and only the unreachable + # nodes stay pending. Failing the whole convergence for a machine that + # happens to be offline hides the real result (rebuildup/pc-setup#289). + Add-Step 'devices-sync' 'pending' ('some devices are unreachable or rejected; the local definitions are applied and the unreachable nodes stay pending; see ' + $script:LogFile) + } + else { Add-Step 'devices-sync' 'error' ('devices sync exited ' + $code + '; see ' + $script:LogFile) } } diff --git a/scripts/ci.sh b/scripts/ci.sh index 31f0e080..9b082d3a 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -400,6 +400,15 @@ PY grep -Fq 'bash scripts/apply-platform.sh' mise.toml +printf 'Checking the devices sync failure classification...\n' +# Another machine's reachability is not this machine's configuration state. A +# devices sync that fails only because a node is unreachable is recorded as +# pending, so the hourly convergence keeps reporting the real result +# (rebuildup/pc-setup#289). +grep -Fq "unavailable or rejected" scripts/converge.sh +grep -Fq "record devices-sync pending" scripts/converge.sh +grep -Fq "Add-Step 'devices-sync' 'pending'" platforms/windows-11/converge.ps1 + printf 'Checking macOS Kanata service contract...\n' python3 - <<'PY' import plistlib diff --git a/scripts/converge.sh b/scripts/converge.sh index 8ab1ce2f..9f8971c7 100755 --- a/scripts/converge.sh +++ b/scripts/converge.sh @@ -319,11 +319,22 @@ sync_devices() { fi local rc=0 - if (cd "$dotfiles_dir" && PATH="$HOME/.local/share/mise/shims:$PATH" bun "$devices_script" sync >"$log_file" 2>&1); then + local devices_output="" + if devices_output="$(cd "$dotfiles_dir" && PATH="$HOME/.local/share/mise/shims:$PATH" bun "$devices_script" sync &1)"; then + printf '%s\n' "$devices_output" >>"$log_file" record devices-sync ok "devices sync converged" else rc=$? - record devices-sync error "devices sync exited $rc; see $log_file" + printf '%s\n' "$devices_output" >>"$log_file" + # Another machine's reachability is not this machine's configuration state: + # the local definitions were applied and only the unreachable nodes stay + # pending. Failing the whole convergence for a machine that happens to be + # offline hides the real result (rebuildup/pc-setup#289). + if printf '%s' "$devices_output" | grep -Fq 'unavailable or rejected'; then + record devices-sync pending "some devices are unreachable or rejected; the local definitions are applied and the unreachable nodes stay pending; see $log_file" + else + record devices-sync error "devices sync exited $rc; see $log_file" + fi fi }