Fix intermittent installer hang on Windows#68870
Open
twangboy wants to merge 2 commits intosaltstack:3006.xfrom
Open
Fix intermittent installer hang on Windows#68870twangboy wants to merge 2 commits intosaltstack:3006.xfrom
twangboy wants to merge 2 commits intosaltstack:3006.xfrom
Conversation
Fix intermittent silent-mode installer hang on Windows; add NSIS test infrastructure
Upstream 3006.x worked around a known silent-mode installer hang with
a wmic process kill — deprecated on Windows 11 and unreliable. This
change fixes the root causes and replaces the workaround.
Salt-Minion-Setup.nsi:
- Replace wmic kill in .onInstSuccess and un.onUninstSuccess with
System::Call "kernel32::ExitProcess(i 0)" guarded by ${If} ${Silent}.
ExitProcess bypasses the NSIS message loop entirely, avoiding the
cross-thread deadlock between the exec thread and UI thread that
caused the hang.
- Replace nsExec::ExecToStack for service start with
SimpleSC::StartService "salt-minion" "" 30. SimpleSC calls the SCM
API inside the plugin DLL with no child process, pipe, or handle
inheritance — eliminating the deadlock source.
- Replace nsExec::ExecToStack for stop/remove in un.uninstallSalt with
SimpleSC::StopService (wait_for_file_release=1, timeout=30) and
SimpleSC::RemoveService. Remove the 6-second sleep and three-pass
PowerShell kill loop that were compensating for the old approach.
- Switch all nsExec::ExecToStack ssm.exe set calls in -Post and
.onInstSuccess to nsExec::Exec (fire-and-forget); configuration
commands need no stdout capture.
- Add taskkill belt-and-suspenders after SimpleSC stop/remove.
- Guard SetAutoClose true in uninstallSalt with !ifdef __UNINSTALL__
so it does not fire during the upgrade path (.onInit calling
uninstallSalt).
- Add SetAutoClose true in .onInit for silent mode and un.onInit.
- Push/Pop $R0 around Call uninstallSalt in .onInit: GetParent inside
the function writes to $R0, clobbering the saved silent flag used
to conditionally restore SetSilent normal afterward.
- Fix typo "mnually" and add missing Quit after VCRedist error.
- Remove InstallDirRegKey (unused).
conftest.py:
- Replace subprocess.PIPE with subprocess.DEVNULL. NSIS Exec passes
inherited pipe handles to child processes (nssm, salt-minion), which
hold the write-end open indefinitely; proc.communicate() never sees
EOF, causing the test to block forever.
- Replace proc.communicate() with proc.wait() for the same reason.
- Reduce run_command timeout from 300 to 60 seconds.
- Add _kill_process_tree() to terminate the entire process hierarchy
on timeout (not just the top-level installer process).
- Return True/False from run_command and assert in install_salt so
a force-kill fails the test — detecting hangs is the purpose of
this suite.
- Add _wait_for_processes() with SCM registry polling: waits for all
PROCESSES to exit, INSTDIR to be deleted, and the salt-minion SCM
key to disappear before the next iteration. Prevents
ERROR_SERVICE_MARKED_FOR_DELETE races between iterations.
- Fix duplicate Un_D.exe entry in PROCESSES (should be Un_E.exe).
Test stubs (new files):
- stubs/daemon/: Go program that blocks on SIGINT, used as a
realistic salt-minion.exe stub that NSSM can manage as a service.
- stubs/exit/: Go program that exits immediately with code 0, used
as vcredist stub so ExecWait in the installer succeeds.
setup.ps1 / quick_setup.ps1:
- Build stubs with go build -C <module-dir> so Go module resolution
finds go.mod regardless of the caller's working directory.
- Replace fake Set-Content vcredist binaries with real go build output.
- Add Go 1.20+ prerequisite check: look in PATH, then fall back to
C:\Program Files\Go and C:\Go; download and install silently from
salt-windows-deps if missing.
install_nsis.ps1:
- Update NSIS download URL from 3.10 to 3.11.
- Add SimpleSC plugin install section (ANSI + Unicode DLLs from
nsis-plugin-simplesc.zip and nsis-plugin-simplescu.zip).
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 does this PR do?
Fix intermittent silent-mode installer hang on Windows; add NSIS test infrastructure
Upstream 3006.x worked around a known silent-mode installer hang with a wmic process kill — deprecated on Windows 11 and unreliable. This change fixes the root causes and replaces the workaround.
Salt-Minion-Setup.nsi:
conftest.py:
Test stubs (new files):
setup.ps1 / quick_setup.ps1:
install_nsis.ps1:
test.ps1:
NSIS Config Tests Log.txt
NSIS Stress Tests Log.txt
Previous Behavior
NSIS Tests were failing, but not reporting failure.
Installer would hang intermittently.
New Behavior
Test failiures now bubble up.
Installer doesn't hang.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes