You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reconcile a deferred reboot already performed out-of-band - #69
Fixes an unnecessary double reboot found during the v5.1.0-preview.5 live test (WFE1/WFE2).
When an automatic reboot is deferred (a CU install returned "reboot required" outside the Reboot.Schedule window), SPSUpdate writes a .pending marker and performs the restart on the next in-window run. If the server was rebooted out-of-band in the meantime — a manual restart, or a Windows Update reboot — the pending request was still honoured and the server was restarted again.
Fix
Before acting on a deferred pending request ($hasPending and no fresh -RebootRequired from an install this run), compare the server's LastBootUpTime with the .pending marker timestamp. If the server has booted after the request was recorded, the required restart already happened out-of-band: write the .done guard, clear the .pending marker, set the Reboot phase to Done ("Reboot already completed out-of-band"), log an informational event, and skip the restart. A reboot required by an install performed this run is unaffected (new binaries still need a restart).
PSScriptAnalyzer 0 issues on src; Pester 296 passed / 0 failed / 1 skipped. The reboot path is Windows-only (uses Get-CimInstance Win32_OperatingSystem) and not unit-tested, consistent with the rest of that action.
Note: targets the 5.x line (main); to be cherry-picked to support/4.x.
When a reboot was deferred (install returned 17022 outside the Reboot.Schedule
window), a .pending marker is written and honoured on the next in-window run. If
the server was rebooted out-of-band in the meantime (manual restart or Windows
Update), SPSUpdate restarted it again unnecessarily.
Before acting on a deferred pending request (no fresh -RebootRequired this run),
compare the server's LastBootUpTime with the .pending marker timestamp: if the
server booted after the request was recorded, mark the Reboot phase Done
('Reboot already completed out-of-band'), clear the pending marker and skip the
restart. A reboot required by an install performed this run is unaffected.
Refs #68
Out-of-band reconciliation only applies to a stale deferred request. If this run
performed an install and Reboot.Force is enabled (exit 0, no 17022), the freshly
installed binaries still need a restart; excluding (Force -and InstallPerformed)
lets that case fall through to the normal reboot/schedule decision instead of
being marked Done by a stale, already-satisfied pending marker.
Refs #68
Compare timestamps in UTC to handle DST fall-back correctly
src/SPSUpdate.ps1:642
Compare these timestamps in UTC. DateTime ordering compares clock ticks rather than normalizing time zones. Across a daylight-saving fall-back, a pending request at 01:50 -04:00 followed by a boot at 01:10 -05:00 can fail this check even though the reboot happened 20 minutes later. The pending request then remains eligible for another restart. Normalize both values to UTC before comparing.
The .pending marker carries an offset (Get-Date -Format o) while CIM
LastBootUpTime is local. Comparing local wall-clock ticks can miss a completed
reboot during the DST fall-back hour (an earlier local tick for a physically
later boot). Normalize the pending timestamp (DateTimeOffset.UtcDateTime) and
LastBootUpTime (ToUniversalTime) to UTC before comparing.
Refs #68
Addressed the DST fall-back finding in 4702bcc: both timestamps are now compared in UTC — the .pending marker is parsed via [datetimeoffset]::Parse(...).UtcDateTime and LastBootUpTime is normalized with .ToUniversalTime(), removing the local wall-clock ambiguity during the DST fall-back hour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request (PR) description
Fixes an unnecessary double reboot found during the v5.1.0-preview.5 live test (WFE1/WFE2).
When an automatic reboot is deferred (a CU install returned "reboot required" outside the
Reboot.Schedulewindow), SPSUpdate writes a.pendingmarker and performs the restart on the next in-window run. If the server was rebooted out-of-band in the meantime — a manual restart, or a Windows Update reboot — the pending request was still honoured and the server was restarted again.Fix
Before acting on a deferred pending request (
$hasPendingand no fresh-RebootRequiredfrom an install this run), compare the server'sLastBootUpTimewith the.pendingmarker timestamp. If the server has booted after the request was recorded, the required restart already happened out-of-band: write the.doneguard, clear the.pendingmarker, set the Reboot phase toDone("Reboot already completed out-of-band"), log an informational event, and skip the restart. A reboot required by an install performed this run is unaffected (new binaries still need a restart).This Pull Request (PR) fixes the following issues
Task list
src; Pester 296 passed / 0 failed / 1 skipped. The reboot path is Windows-only (usesGet-CimInstance Win32_OperatingSystem) and not unit-tested, consistent with the rest of that action.