[9.4] (backport #13710) Remove Go 1.24 workaround in Windows uninstall#13905
Merged
Conversation
* Remove Go 1.24 workaround in Windows uninstall * Drop some unnecessary comments (cherry picked from commit 2b8c0aa)
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
4 tasks
swiatekm
approved these changes
Apr 29, 2026
Contributor
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?
Removes a workaround for uninstall on Windows that we added with the upgrade to Go 1.25 in #10156. We go back to using the Go standard library's
os.RemoveAlland fix the underlying issue.The underlying issue is roughly that our logic to delete the running executable never worked correctly, and since we ignore errors from it, we never realized. It so happened that the part that did work was sufficient for the more permissive
os.RemoveAllimplementation from Go 1.24, but not the one from Go 1.25.The fix is simply to not reopen the file handle after renaming the Alternate Data Stream. Then deleting the handle succeeds and
os.RemoveAllskips over the entry when enumerating directory content.I added a fairly verbose test that checks the status of the handle after each step using windows syscalls. The intent of it is to explain how and why it works. See this comment for a high level summary of the underlying semantics.
For completeness' sake, the removeBlockingExe implementation has various other problems that don't impact the effectiveness, but make the whole thing more confusing. I'm planning to fix those in a follow-up and add more tests. This fix is intentionally minimal to make it easier to understand.
Why is it important?
Our uninstall process should be understandable rather than mysterious.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added an entry in./changelog/fragmentsusing the changelog tool[ ] I have added an integration test or an E2E testRelated issues
This is an automatic backport of pull request #13710 done by [Mergify](https://mergify.com).