Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified TemporaryDirectoryAllocator.dispose #198

Merged
merged 11 commits into from
May 19, 2023

Conversation

jglick
Copy link
Member

@jglick jglick commented Jan 22, 2020

Experience in jenkinsci/jenkins#4447 shows that the FilePath- and thus PathRemover-based implementation does not work reliably in Windows CI after #166, and we get stuff like #185 which is making things more complicated than it really needs to be. In a test, we

  • expect deletion to succeed, so there is no need to collect errors—fail on the first one
  • do not care to retry deletions like we might in production
  • do not expect there to be unwritable files

@jglick jglick requested a review from jtnord January 22, 2020 22:17
Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me - but I would generally not require a run of the gc as stated

jglick added a commit to jglick/jenkins that referenced this pull request Jan 22, 2020
@slonopotamus
Copy link
Contributor

#166 does not guarantee it will detect a bug. But if it detects something, you may be sure that there is a bug in code. I want to say that "able to detect bugs unreliably" is better than "unable to detect bugs". The point of #166 is not to delete directory. Nobody cares if it is deleted or not, actually! The point is to catch buggy code that forgot to close file descriptors after finishing.

jenkinsci/git-plugin#798, jenkinsci/subversion-plugin#240 and jenkinsci/workflow-support-plugin#99 were all actual bugs in production code of plugins, discovered thanks to #166.

@slonopotamus
Copy link
Contributor

slonopotamus commented Jan 22, 2020

If you need some help figuring out what exact code is guilty in failed tests in jenkinsci/jenkins#4447 - I can definitely do that.

@jglick jglick marked this pull request as ready for review October 7, 2020 20:15
@jglick
Copy link
Member Author

jglick commented Oct 7, 2020

I see no reason to hold off on this PR just because jenkinsci/jenkins#4447 is stalled.

@jglick jglick requested a review from jtnord October 7, 2020 20:17

private void delete(Path p) throws IOException {
LOGGER.fine(() -> "deleting " + p);
if (Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably also a junction which I think may be used in some test case and FIlePath respects.. (FIles.readAttributes and isOther - as a general well it is not a normal directory)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know much about junctions. Would they ever really be used in $JENKINS_HOME?

Copy link
Member

@jtnord jtnord Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure something uses them as we have specific code in Jenkins...
https://github.com/jenkinsci/jenkins/blob/715cdb15b3e855f8b6115aa02200860ed6caf49d/core/src/main/java/hudson/Util.java#L323-L343
I have not come across a real life example, but I'm guessing that it is for a reason?

Maybe it is just an easy way in Jenkins to put some subset of Jobs in a different drive / pool etc and would not actually be done inside a workspace, or a build directory by jenkins (I do not know if zipping on windows copies the Junction or not, so if a workspace was coppied from an agent where the build created a junction if that would be replcicated on a master).

ec2 plugin seems to use them for something?
https://github.com/jenkinsci/ec2-plugin/blob/20f0c2406d62ddbd0d005a2fb15f3f9bb95b3f20/src/main/java/hudson/os/WindowsUtil.java#L109-L121

and the workspacebrowser has a test to prevent traversing them IIRC (so there is at least one use in Jenkins where a workspace will have junctions) https://github.com/jenkinsci/jenkins/blob/9330635821cbcb430b4223b471692f2c9ae862db/test/src/test/java/hudson/model/DirectoryBrowserSupportTest.java#L617

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be some obscure use case in production servers, but I doubt this would affect functional tests. If there is some plugin which does create a junction during a test for some reason, then it can explicitly remove it before generic cleanup, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick jglick marked this pull request as draft October 12, 2020 15:34
@jglick
Copy link
Member Author

jglick commented May 18, 2023

Tested successfully in jenkinsci/jenkins#8006 which I think is good enough.

@jglick jglick marked this pull request as ready for review May 18, 2023 11:29
@jglick jglick requested a review from jtnord May 18, 2023 11:29
jglick added a commit to jglick/jenkins that referenced this pull request May 18, 2023

private void delete(Path p) throws IOException {
LOGGER.fine(() -> "deleting " + p);
if (Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick jglick enabled auto-merge May 19, 2023 18:27
@jglick jglick merged commit 4f7e40a into jenkinsci:master May 19, 2023
NotMyFault pushed a commit to jenkinsci/jenkins that referenced this pull request May 21, 2023
…ryAllocator.dispose` change) (#8006)

* Testing `TemporaryDirectoryAllocator.dispose` change

* `QueueTest.pendingsConsistenceAfterErrorDuringMaintain` should wait for completion of any builds it started

* Close a `FileOutputStream` in `LauncherTest.remotable`

* `DirectoryBrowserSupportTest.junctionAndSymlink_outsideWorkspace_areNotAllowed_windowsJunction` to clean up junctions it created

* Reverting temporary dep on jenkinsci/jenkins-test-harness#198

* Commenting reason for `rmdir /s /q` #8006 (review)
@basil
Copy link
Member

basil commented May 29, 2023

Caused #591.

@basil
Copy link
Member

basil commented Jun 6, 2023

Caused JENKINS-71406.

@slonopotamus
Copy link
Contributor

Well, if this change exposes bugs in code, it's not this change fault that other code is buggy.

@MarkEWaite
Copy link
Contributor

MarkEWaite commented Jun 7, 2023

Well, if this change exposes bugs in code, it's not this change fault that other code is buggy.

I agree that it is not the fault of this change that other code has bugs. However, it seems important to the overall progress of the project that when general behavior (tests passing reliably) regresses, it is better to either fix the problems that have been exposed by the change or revert the change that exposed the problems. Remaining for an extended period in a state where tests are flaky (the problem is exposed but not resolved) will reduce our ability to trust the tests and our ability to add new capabilities.

It is a good thing that we see the problems, but if we can't resolve the problems that we now see (in a reasonable amount of time and effort), then I think it is healthier for the project to return to hiding the problems (by reverting the change) rather than slow further progress with the distraction of seeing those problems.

@jglick
Copy link
Member Author

jglick commented Jun 7, 2023

Commented in Jira. Please keep discussion there.

@basil
Copy link
Member

basil commented Jun 21, 2023

Caused #612.

@basil
Copy link
Member

basil commented Aug 19, 2023

@jglick This PR is causing problems in https://github.com/jenkinsci/copyartifact-plugin

@jglick
Copy link
Member Author

jglick commented Aug 21, 2023

@basil
Copy link
Member

basil commented Sep 14, 2023

@jglick This PR is causing problems in jenkinsci/workflow-cps-global-lib-http-plugin#167

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.

5 participants