Skip to content

[9.4](backport #54612) ci: don't fail Windows winlogbeat jobs when the Sysmon temp folder can't be removed - #54626

Merged
marc-gr merged 1 commit into
9.4from
mergify/bp/9.4/pr-54612
Nov 12, 2026
Merged

marc-gr merged 1 commit into
9.4from
mergify/bp/9.4/pr-54612

Conversation

@mergify

@mergify mergify Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Proposed commit message

install_sysmon.ps1 ends by deleting the temp folder it downloaded
Sysmon64.exe into. On a Win 2016 agent that delete failed with "Access to
the path 'Sysmon64.exe' is denied", most likely because the file was still
open (for example by antivirus) right after Sysmon64.exe -m exited. The
error failed the step before mage build unitTest ran, so a job with nothing
wrong in it went red.

Retry the delete up to five times, two seconds apart, and if the folder still
can't be removed, log a warning and carry on: nothing uses it afterwards. The
download and the manifest installation are unchanged, and a failed download
still fails the job.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None. This only changes a CI setup script.

How to test this PR locally

The script only runs on the Buildkite Windows agents, through the
x-pack/winlogbeat Windows unit test jobs in
.buildkite/x-pack/pipeline.xpack.winlogbeat.yml. Those jobs on this PR
exercise the normal path.

The new cleanup block was also run on its own in Windows PowerShell 5.1 with
$ErrorActionPreference = 'Stop':

  • With Sysmon64.exe held open, it retried, logged the warning after about
    8 seconds, and finished without an error.
  • With the file not held open, it removed the folder.

Related issues

Logs

Sysmon64.exe downloaded successfully.
Sysmon event manifest installation completed.
Remove-Item : Cannot remove item C:\Users\buildkite\AppData\Local\Temp\SysmonDownload\Sysmon64.exe: Access to the path
'Sysmon64.exe' is denied.
At C:\buildkite-agent\builds\...\.buildkite\scripts\install_sysmon.ps1:56 char:1
+ Remove-Item -Path $tempFolder -Force -Recurse
    + CategoryInfo          : PermissionDenied: (Sysmon64.exe:FileInfo) [Remove-Item], UnauthorizedAccessException
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
🚨 Error: The command exited with status 1

🤖 Generated with Claude Code


This is an automatic backport of pull request #54612 done by [Mergify](https://mergify.com).

…n't be removed (#54612)

install_sysmon.ps1 ends by deleting the folder it downloaded Sysmon64.exe
into. On a Win 2016 agent that delete failed with "Access to the path
'Sysmon64.exe' is denied", likely because the file was still open (for
example by antivirus) right after Sysmon64.exe -m exited. The error
failed the step before mage build unitTest ran, so a job with nothing
wrong in it went red.

Retry the delete a few times, two seconds apart, and if the folder still
can't be removed, log a warning and carry on: nothing uses it afterwards.

Assisted-By: Claude Code
(cherry picked from commit 79b438c)
@mergify
mergify Bot requested a review from a team as a code owner November 11, 2026 12:33
@mergify mergify Bot added the backport label Nov 11, 2026
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 11, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@mergify

mergify Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is merged.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency review finished without posting an analysis comment.

If you expected a review, push a new commit to this pull request (or close and reopen it) to try again.

Workflow run: https://github.com/elastic/beats/actions/runs/43021351053

@marc-gr
marc-gr merged commit 7d5385c into 9.4 Nov 12, 2026
225 checks passed
@marc-gr
marc-gr deleted the mergify/bp/9.4/pr-54612 branch November 12, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant