Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions pkg/configurer/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ func isExitCode3010(err error) bool {
// TODO: move this fix upstream into the k0sproject/rig Windows configurer.
func (c WindowsConfigurer) Reboot(h os.Host) error {
const taskName = "LaunchpadReboot"
// Create a SYSTEM-context ONSTART task that runs 'shutdown /r /f /t 5'.
// The 5-second delay gives us time to delete the task before the OS
// actually executes the reboot, preventing it from firing again on the
// next startup.
// The ONSTART trigger means the task will re-fire on the next startup, but
// the post-reboot cleanup in InstallMCR deletes it once the host is back up.
create := fmt.Sprintf(`schtasks /create /tn "%s" /tr "shutdown /r /f /t 5" /sc onstart /f /ru SYSTEM`, taskName)
if err := h.Exec(create); err != nil {
return fmt.Errorf("failed to create reboot task: %w", err)
Expand All @@ -160,14 +158,6 @@ func (c WindowsConfigurer) Reboot(h os.Host) error {
return fmt.Errorf("failed to run reboot task: %w", err)
}
}
// Delete the task immediately while the 5-second shutdown timer is still
// counting down. This prevents it from re-firing on subsequent startups.
del := fmt.Sprintf(`schtasks /delete /tn "%s" /f`, taskName)
if err := h.Exec(del); err != nil {
// Best-effort: warn but don't fail — the post-reboot cleanup in
// InstallMCR will attempt deletion again once the host is back up.
log.Warnf("%v: failed to pre-delete reboot task (will retry after reboot): %s", h, err)
}
// Allow Windows time to complete shutdown before waitForHost begins polling.
time.Sleep(15 * time.Second)
return nil
Expand Down
Loading