From 70c147b47d78332fe86e35aff73fc9def8710e58 Mon Sep 17 00:00:00 2001 From: "goodolclint-claude[bot]" <323206664+goodolclint-claude[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:47:41 +0000 Subject: [PATCH] fix: post-loop fallback tests the latest poll, not "ever matched" Review finding on #97: `statusReached` was sticky, so a guest that reached the expected status once and then drifted away from it would still be reported as a success at the deadline, contradicting the fallback's own meaning. Track the most recent observation instead. A guest that drifts away and never re-matches now raises PveTaskTimeoutException as it should. A failed poll leaves the previous observation standing, so an API blip is not read as divergence. Co-Authored-By: Claude Opus 5 (1M context) --- src/PSProxmoxVE/Cmdlets/PveCmdletBase.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PSProxmoxVE/Cmdlets/PveCmdletBase.cs b/src/PSProxmoxVE/Cmdlets/PveCmdletBase.cs index ab10e0b..c07e6f9 100644 --- a/src/PSProxmoxVE/Cmdlets/PveCmdletBase.cs +++ b/src/PSProxmoxVE/Cmdlets/PveCmdletBase.cs @@ -131,7 +131,7 @@ namespace PSProxmoxVE.Cmdlets : $"nodes/{Uri.EscapeDataString(node)}/qemu/{vmid}/status/current"; var deadline = DateTime.UtcNow.AddSeconds(timeoutSeconds); - var statusReached = false; + var lastMatched = false; using var pollClient = new PveHttpClient(session); while (DateTime.UtcNow < deadline) { @@ -139,11 +139,10 @@ namespace PSProxmoxVE.Cmdlets { var json = pollClient.GetAsync(statusResource).GetAwaiter().GetResult(); var snapshot = GuestStatusSnapshot.Evaluate(json, expectedStatus); + lastMatched = snapshot.StatusMatched; if (snapshot.StatusMatched) { - statusReached = true; - // PVE reports the target status before the operation releases the // config lock. A caller that issues its next request inside that // window gets "can't lock file '/var/lock/qemu-server/lock-.conf' @@ -160,8 +159,9 @@ namespace PSProxmoxVE.Cmdlets System.Threading.Thread.Sleep(2000); } - // Status reached and only the lock outlasted the deadline. - if (statusReached) + // The guest still reports the expected status on the final poll and only the + // lock outlasted the deadline. + if (lastMatched) return task; throw new PveTaskTimeoutException(