Windows agent: job cleanup fails on read-only files (`.git` pack files) #3170
Thomas Pierrard opened 9 hours ago

Hello!

Since upgrading OneDev, jobs on our Windows agent fail at cleanup with:

Error executing job: java.util.concurrent.ExecutionException: ...
java.lang.RuntimeException: Failed to delete path 'C:\onedev_agent\agent\work\temp\onedev-build-276-55-5'
    at io.onedev.server.job.DefaultJobService.lambda$execute$8(DefaultJobService.java:703)
    ...

The same jobs cleaned up fine before the upgrade.

Environment

  • OneDev server: 16.8.4 (agent updated along with server)
  • Agent OS: Windows, agent running as a service (domain account, member of local Administrators, High integrity level, Full Control on the work dir)
  • Agent JVM: OpenJDK 21.0.1 (build 21.0.1+12-29)

Analysis

  • Permissions are not the issue: the service account has full control, and a manual Remove-Item -Recurse -Force on the same directory succeeds.
  • The directory contains read-only files created by git:
    • work\.git\objects\pack\pack-*.pack / *.idx (job checkout)
  • From a job step, deleting a read-only file with a plain delete fails with Access denied, while clearing the attribute first works.
  • So the agent's delete apparently no longer clears the read-only attribute before deleting. This is perhaps a switch from java.io.File.delete() (which handles read-only on Windows) to java.nio.file.Files.delete() (which doesn't).

Workaround

A final step with condition Always that runs:

attrib -r "<build dir>\*" /s /d

Regards, Thomas

  • Robin Shen changed title 7 hours ago
    Previous Value Current Value
    Windows agent: job cleanup fails on read-only files (`.git` pack files) since upgrade to 16.8.4
    Windows agent: job cleanup fails on read-only files (`.git` pack files)
1/1
Type
Bug
Priority
Normal
Assignee
Affected Versions
16.8.4
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-3170
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover