Skip to content

Fix intermittent installer Abort (exit 2) on salt-minion service re-registration#69579

Merged
dwoz merged 1 commit into
saltstack:3006.xfrom
twangboy:fix_nsis_error
Jun 27, 2026
Merged

Fix intermittent installer Abort (exit 2) on salt-minion service re-registration#69579
dwoz merged 1 commit into
saltstack:3006.xfrom
twangboy:fix_nsis_error

Conversation

@twangboy

Copy link
Copy Markdown
Contributor

What does this PR do?

Silent installs intermittently failed with NSIS error level 2 -- a script-driven Abort, not the exit-path hang fixed previously. The only Section Abort reachable on the happy path is the salt-minion service registration: "ssm install salt-minion" (CreateService) returning non-zero.

The cause is an SCM race against the prior uninstall. The uninstaller's SimpleSC::RemoveService only marks the service for deletion; the SCM does not remove the HKLM...\Services\salt-minion key until every open handle closes, which happens asynchronously after the uninstaller has exited. When the next install's CreateService races that pending delete, Windows returns ERROR_SERVICE_MARKED_FOR_DELETE (1072) or ERROR_SERVICE_EXISTS (1073), ssm exits non-zero, and the Section aborts. This is why it only fails occasionally and recovers on the next run -- it is purely a timing window between back-to-back uninstall/install.

Fix it at the point of failure: retry "ssm install" up to 5 times with a 2s pause instead of aborting on first failure. The condition is self-clearing once handles close, so the retry rides it out. This also covers real-world upgrades, where uninstall and reinstall are separate processes and nothing in the uninstaller can constrain a future installer invocation.

As defense-in-depth, also wait (bounded, 10s) in un.Uninstall for the SCM to actually remove the service key -- placed after the salt-minion.exe and ssm.exe taskkills, since the key cannot clear until those handles are gone. This narrows the race window for the common case but is not sufficient alone; the install-side retry remains the authoritative guard.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

…egistration

Silent installs intermittently failed with NSIS error level 2 -- a
script-driven Abort, not the exit-path hang fixed previously. The only
Section Abort reachable on the happy path is the salt-minion service
registration: "ssm install salt-minion" (CreateService) returning
non-zero.

The cause is an SCM race against the prior uninstall. The uninstaller's
SimpleSC::RemoveService only *marks* the service for deletion; the SCM
does not remove the HKLM\...\Services\salt-minion key until every open
handle closes, which happens asynchronously after the uninstaller has
exited. When the next install's CreateService races that pending delete,
Windows returns ERROR_SERVICE_MARKED_FOR_DELETE (1072) or
ERROR_SERVICE_EXISTS (1073), ssm exits non-zero, and the Section aborts.
This is why it only fails occasionally and recovers on the next run --
it is purely a timing window between back-to-back uninstall/install.

Fix it at the point of failure: retry "ssm install" up to 5 times with a
2s pause instead of aborting on first failure. The condition is
self-clearing once handles close, so the retry rides it out. This also
covers real-world upgrades, where uninstall and reinstall are separate
processes and nothing in the uninstaller can constrain a future
installer invocation.

As defense-in-depth, also wait (bounded, 10s) in un.Uninstall for the
SCM to actually remove the service key -- placed after the salt-minion.exe
and ssm.exe taskkills, since the key cannot clear until those handles are
gone. This narrows the race window for the common case but is not
sufficient alone; the install-side retry remains the authoritative guard.
@twangboy twangboy requested a review from a team as a code owner June 26, 2026 14:02
@twangboy twangboy self-assigned this Jun 26, 2026
@twangboy twangboy added the test:full Run the full test suite label Jun 26, 2026
@twangboy twangboy added this to the Sulphur v3006.27 milestone Jun 26, 2026
@dwoz dwoz merged commit 001f8a7 into saltstack:3006.x Jun 27, 2026
863 of 870 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants