Closed cailyoung closed 8 months ago
I'm open to raising a PR for this but I'm not sure whether there's a preference to resolve this in the provisioner itself, or in the remote-end powershell scripts.
@rgl Sorry to ping you; I am happy to work on a PR for this but don't know if you have a preference for which layer the issue is addressed in. I could see adding another case
and just accepting the 2012 return value, or I could see altering the remotely-executed PowerShell to handle Server 2012 (if possible!)
I've never experienced this problem directly, so I have no idea how/where to fix it. Maybe doing a machine reboot helps? If so, reboots are handled by the go code that is running in the host.
Please be aware that I no longer use Windows Server 2012/R2 (I only use 2019/2022).
A reboot clears the problem (The exit code is returned because a reboot is pending, it's just being misinterpreted during communication back to packer).
I'll work up a PR and test it out on our systems. I wish I was also no longer using Server 2012! :D
@rgl - I've raised https://github.com/rgl/packer-plugin-windows-update/pull/134 to fix this issue.
Are you able to take a look and merge in if you're happ?
https://github.com/rgl/packer-plugin-windows-update/blob/6793f6375aa3b786be6ef36d571dc9d35f9f90de/update/provisioner.go#L279 appears to be the plumbing between the restart-required check (that uses a scheduled task under the hood) and the provisioner in order to decide what to do.
On many of our VM builds, this works fine, but on Server 2012 in particular this appears to get stuck, printing
Waiting for the Windows Modules Installer to exit...
to the console and loggingRetryable error: Windows update script exited with non-zero exit status: 2147942501
to the log.It looks like some error/exit code translation is going on - https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- suggests
101
is this semaphore error that was referred to in #78 - perhaps running the task asSYSTEM
causes some weird failure mode in Server 2012 specifically where the result code of the process in the scheduled task is mapped via the system error table?