Skip to content

openjdk\bin keeps being emptied on VM testing-windows #252

Closed

Description

@katre

Earlier today, I noticed that on the testing-windows VM, the C:\openjdk\bin directory (and several others) was empty. @philwo then re-imaged the VM, and everything was fine.

Just now, I logged into the VM again, and c:\openjdk\bin is again empty, with no Java binaries to be found.

Activity

  1. philwo commented on Mar 21, 2018

    @philwo
    Member

    @katre Do you remember if you ran "bazel clean" or "bazel clean --expunge" at some point in time?

    @laszlocsomor I wonder if Bazel is following symlinks for the local JDK, ends up in C:\openjdk and thoroughly "cleans it up" ... any idea?

    FYI, we don't see this on the Buildkite VMs, because there the buildkite user does not have write-permissions to C:, so it can't delete the folder.

  2. katre commented on Mar 21, 2018

    @katre
    ContributorAuthor

    No, I didn't run "bazel clean", although I might have tried to delete my entire bazel checkout in a fit of cleanliness.

  3. philwo commented on Mar 21, 2018

    @philwo
    Member

    I might have tried to delete my entire bazel checkout in a fit of cleanliness.

    How did you delete the checkout? :D

    Some tools in Windows don't understand symbolic links and then follow them. I think this could cause the problem.

  4. katre commented on Mar 21, 2018

    @katre
    ContributorAuthor

    I used "rmdir /s /q". Let me guess, that followed the junction and clobbered openjdk? Lovely.

  5. katre commented on Mar 21, 2018

    @katre
    ContributorAuthor

    Given the number of tests that create bazel workspaces and then clean them up after, this would probably be triggered no matter what I had done.

  6. laszlocsomor commented on Mar 22, 2018

    @laszlocsomor
    Contributor

    @philwo : do you know if anything runs git clean on CI ? I heard that it can delete the JDK, though I haven't tried it myself yet.

  7. laszlocsomor commented on Mar 22, 2018

    @laszlocsomor
    Contributor

    @katre : IIRC rmdir /s /q doesn't follow junctions so that can't be the culprit. (I have to verify this when I get to the office today.)

  8. philwo commented on Mar 22, 2018

    @philwo
    Member

    @laszlocsomor CI does run „git clean“, but the testing-* machines are not used by CI.

  9. philwo commented on Mar 22, 2018

    @philwo
    Member

    Thinking about it, IIRC I initially used „rmdir /s /q“ to clean up after a CI run in the infra scripts and that indeed followed Bazel‘s bazel-out junction and deleted the entire JDK.

  10. philwo commented on Mar 22, 2018

    @philwo
    Member

    After I switched to PowerShell‘s „Remove-Item“ function, this worked fine.

  11. laszlocsomor commented on Mar 22, 2018

    @laszlocsomor
    Contributor

    I tried it just now: neither del /s /q nor rd /s /q follow junctions.

  12. laszlocsomor commented on Mar 22, 2018

    @laszlocsomor
    Contributor

    Ha! del /s /q bazel-bin will follow the junction. Ouch. rd /s /q bazel-bin won't though.

  13. 7 remaining items

  14. katre commented on Mar 27, 2018

    @katre
    ContributorAuthor

    Okay, I was unable to reproduce this by running tests. My assumption then is that I was doing something strange while testing manually and triggered the wrong delete command.

    Thanks for the help, I'll close the issue now.

  15. laszlocsomor commented on Apr 17, 2018

    @laszlocsomor
    Contributor

    @jasharpe found the culprit:

    • When you RDP into Windows, you get a different TMP/TEMP than usual and Windows (or the RDP client?) cleans these directories (seemingly upon restart, but maybe also sooner)
    • Bazel puts the output_base to the TMP directory by default (!!!)
    • The execroot is under the output_base and contains junctions pointing to... all your external repos. And your workspace. And to your JDK.
    • The cleanup logic follows junctions. (sigh)
  16. laszlocsomor commented on Apr 17, 2018

    @laszlocsomor
    Contributor
  17. jasharpe commented on Apr 17, 2018

    @jasharpe

    To add slightly more color:

    • I'm pretty sure Windows is responsible for this. Whether this deletion occurs is controlled by the "HKLM:\System\CurrentControlSet\Control\Terminal Server\DeleteTempDirsOnExit" registry entry (it is 1 by default, and this problem goes away if you set it to 0).

    • This occurs at session end, which is sign out, not restart. It's much faster to reproduce by just signing out (from Powershell you can just do logoff to make this happen).

  18. laszlocsomor commented on Apr 17, 2018

    @laszlocsomor
    Contributor

    That means junctions are inherently dangerous: by default they look like directories, and if a directory-tree deleter routine is unaware of junctions and doesn't check the FILE_ATTRIBUTE_REPARSE_POINT bit (see GetFileAttributes()), they'll blindly follow the junction.

  19. laszlocsomor commented on Apr 17, 2018

    @laszlocsomor
    Contributor

    A better approach would be to do the same as on Linux: create directories with file symlinks in them. That way deleting the directory tree is safe because deleting a file symlink just deletes the symlink.

    The downside is of course that creating symlinks requires admin privileges.

  20. laszlocsomor commented on Apr 17, 2018

    @laszlocsomor
    Contributor

    @philwo pointed out that directory symlinks would be risky on Linux too. And AFAIK we don't even create directory symlinks on any platform other than Windows.

    @dslomov : FYI.

    The implications:

    • we have to abstain from creating junctions
    • we need to create symlink forests (directory trees with file symlinks)
    • we need admin privileges, or at least some specific permissions to use CreateSymbolicLink
    • therefore we may need to give up the "xcopy install" concept, add an installer, and require admin approval
  21. laszlocsomor commented on May 16, 2018

    @laszlocsomor
    Contributor

    bazelbuild/bazel#5038 is closed and released in 0.13.0 so this bug should no longer occur.

    The implications:

    On second thought, we cannot fix the Remote Desktop server not to follow junctions while deleting the temp directory, and abstaining from using junctions would limit the usability of Bazel, particularly on older Windows versions that don't support unprivileged symlink creation. Therefore I think Bazel is working as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions