Repository navigation
daemon: improve Windows service registration cleanup, and make un-registration idempotent - #53845
Merged
Merged
Conversation
Delete the Windows service before removing its event log source, so a failure to delete the service does not leave an installed service without its event log registration. Also propagate errors from eventlog.Remove instead of silently ignoring them. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Remove the Windows service if registration fails after it was created, preventing a partially configured service from being left behind. Keep the original registration error and treat errors encountered while rolling back or closing the service handle as best-effort cleanup. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Treat an already absent service or one already marked for deletion as a successful unregister operation. Continue removing the event log registration in those cases so retries also clean up stale registration state left by an earlier partial unregister. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The Windows cleanup paths correctly preserve primary errors while safely handling partial or repeated operations.
Review effort: Balanced
Findings: None
What changed in this PR
Improves reliability and idempotency of Windows service registration cleanup.
Changes:
- Rolls back service creation when registration fails.
- Deletes services before removing event-log registration.
- Treats absent services, pending deletion, and missing event-log keys as successful cleanup.
| File | Description |
|---|---|
daemon/command/service_windows.go |
Adds transactional registration cleanup and idempotent unregistration behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
corhere
approved these changes
Oct 6, 2026
3 tasks
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.
daemon: handle Windows event log removal errors
Delete the Windows service before removing its event log source, so a
failure to delete the service does not leave an installed service without
its event log registration.
Also propagate errors from eventlog.Remove instead of silently ignoring
them.
daemon: clean up Windows service after registration failure
Remove the Windows service if registration fails after it was created,
preventing a partially configured service from being left behind.
Keep the original registration error and treat errors encountered while
rolling back or closing the service handle as best-effort cleanup.
daemon: make Windows service unregistration idempotent
Treat an already absent service or one already marked for deletion as a
successful unregister operation.
Continue removing the event log registration in those cases so retries
also clean up stale registration state left by an earlier partial
unregister.
Release notes (optional)
A picture of a cute animal (not mandatory but encouraged)