fix: validate Windows node reset task result#8970
Open
r2k1 wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2ba2b88c-27a6-4f9b-9fd5-bf757a9d31c2
r2k1
requested review from
AbelHu,
Devinwong,
SriHarsha001,
awesomenix,
calvin197,
cameronmeissner,
djsly,
ganeshkumarashok,
karenychen,
lilypan26,
mxj220,
pdamianov-dev,
phealy,
runzhen,
sulixu,
surajssd,
timmy-wright,
titilambert,
xuexu6666 and
zachary-bailey
as code owners
July 17, 2026 04:29
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens Windows NodePrep’s handling of the k8s-restart-job scheduled task by validating that a new task run occurred and that it completed successfully, and by adding Pester coverage for key success/failure paths.
Changes:
- Add
Start-NodeResetScriptTaskhelper to wait for a new scheduled-task run and validateLastTaskResultand kubelet status. - Refactor
NodePrepto call the new helper instead of inlining task polling logic. - Add Pester tests covering success, pre-start
Ready, failed task result, and kubelet-not-running scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| parts/windows/windowscsehelper.ps1 | Introduces Start-NodeResetScriptTask to validate task completion using LastRunTime/LastTaskResult and kubelet state. |
| parts/windows/kuberneteswindowssetup.ps1 | Replaces inline scheduled-task wait logic with a call to Start-NodeResetScriptTask from NodePrep. |
| parts/windows/windowscsehelper.tests.ps1 | Adds Pester coverage for success and failure modes of Start-NodeResetScriptTask. |
| return [pscustomobject]@{ LastRunTime = [datetime]"2026-01-02"; LastTaskResult = 1 } | ||
| } | ||
|
|
||
| { Start-NodeResetScriptTask } | Should -Throw "*failed with result [1]*" |
Comment on lines
+335
to
+338
| $kubeletService = Get-Service -Name "kubelet" -ErrorAction SilentlyContinue | ||
| if ($null -eq $kubeletService -or $kubeletService.Status -ne "Running") { | ||
| Set-ExitCode -ExitCode $global:WINDOWS_CSE_ERROR_START_NODE_RESET_SCRIPT_TASK -ErrorMessage "kubelet service is not running after NodeResetScriptTask completed" | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does / why we need it:
Windows NodePrep currently treats the
k8s-restart-jobscheduled task returning toReadyas success.Readyonly means the task is idle: it can also be observed before the new run starts or after a failed run.This change:
LastRunTimeto change;LastTaskResultis nonzero;Ready, failed-task, and stopped-kubelet paths.Which issue(s) this PR fixes:
N/A