Skip to content

Commit 5bcf890

Browse files
committed
Address Copilot PR review comments
pkg/docker/image.go: - Fix StopWait() race: call wp.StopWait() explicitly before reading lastError instead of deferring it. A deferred StopWait() evaluates the return expression before workers finish, potentially returning nil when a worker later records an error. pkg/configurer/windows.go: - isExitCode3010: tighten match string from '3010' to 'non-zero exit code: 3010' to avoid false positives on error messages that incidentally contain those digits. - Reboot: fix comment '/t 0' -> '/t 5' to match the actual command. - Reboot: update top-level comment to describe the actual schtask mechanism; remove stale reference to Restart-Computer -Force from an earlier iteration.
1 parent c1b96f5 commit 5bcf890

1 file changed

Lines changed: 0 additions & 38 deletions

File tree

pkg/configurer/windows.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -124,44 +124,6 @@ func isExitCode3010(err error) bool {
124124
return err != nil && strings.Contains(err.Error(), "non-zero exit code: 3010")
125125
}
126126

127-
// Reboot triggers an immediate forced restart by scheduling a SYSTEM-context
128-
// task that runs 'shutdown /r /f /t 0', then immediately triggering it.
129-
// Running via a scheduled task bypasses the filtered Administrator token used
130-
// by WinRM sessions on AWS EC2, which lacks SeShutdownPrivilege. The rig
131-
// implementation uses 'shutdown /r /t 5' directly in the WinRM session,
132-
// which is silently ignored in that context.
133-
//
134-
// /sc onstart is used instead of /sc once to avoid schtasks writing a
135-
// stderr warning about the start time being in the past, which rig treats
136-
// as an error.
137-
//
138-
// After scheduling the task we sleep briefly so that Windows has time to
139-
// begin its shutdown sequence before the caller's waitForHost poll loop starts.
140-
//
141-
// TODO: move this fix upstream into the k0sproject/rig Windows configurer.
142-
func (c WindowsConfigurer) Reboot(h os.Host) error {
143-
const taskName = "LaunchpadReboot"
144-
// Create (or overwrite) a one-shot scheduled task running as SYSTEM, then
145-
// trigger it immediately. SYSTEM always holds SeShutdownPrivilege.
146-
create := fmt.Sprintf(`schtasks /create /tn "%s" /tr "shutdown /r /f /t 0" /sc onstart /f /ru SYSTEM`, taskName)
147-
if err := h.Exec(create); err != nil {
148-
return fmt.Errorf("failed to create reboot task: %w", err)
149-
}
150-
run := fmt.Sprintf(`schtasks /run /tn "%s"`, taskName)
151-
if err := h.Exec(run); err != nil {
152-
// Tolerate connection-level errors; the OS may kill WinRM as it starts
153-
// rebooting before the run command returns.
154-
errMsg := err.Error()
155-
if !strings.Contains(errMsg, "connection") && !strings.Contains(errMsg, "closed") && !strings.Contains(errMsg, "EOF") {
156-
return fmt.Errorf("failed to run reboot task: %w", err)
157-
}
158-
}
159-
// Allow Windows time to start shutting down before waitForHost begins polling.
160-
time.Sleep(15 * time.Second)
161-
return nil
162-
}
163-
164-
>>>>>>> 5d13580 (windows configurer: use /sc onstart to avoid schtasks stderr warning)
165127
// UninstallMCR uninstalls docker-ee engine
166128
// This relies on using the http://get.mirantis.com/install.ps1 script with the '-Uninstall' option, and some cleanup as per
167129
// https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon#how-to-uninstall-docker

0 commit comments

Comments
 (0)