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

[JENKINS-37098] don’t rely on ReopenableFileOutputStream #2490

Merged
merged 1 commit into from
Aug 8, 2016
Merged

[JENKINS-37098] don’t rely on ReopenableFileOutputStream #2490

merged 1 commit into from
Aug 8, 2016

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Aug 1, 2016

ReopenableFileOutputStream introduces file-leaks (detected on windows) when channel onClose writes on already closed log, and breaks when computer tries to delete the slave’s log directory.

see JENKINS-37098

@ndeloof ndeloof added the needs-more-reviews Complex change, which would benefit from more eyes label Aug 1, 2016
@ndeloof
Copy link
Contributor Author

ndeloof commented Aug 1, 2016

@reviewbybees

@@ -37,6 +37,7 @@
* and then keep writing.
*
* @author Kohsuke Kawaguchi
* @deprecated due to risk for file leak
*/
public class ReopenableFileOutputStream extends OutputStream {
Copy link
Member

Choose a reason for hiding this comment

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

Also needs @Deprecated annotation

@jtnord
Copy link
Member

jtnord commented Aug 1, 2016

@ndeloof Needs a JIRA reference. won't this just cause an IOException on windows as onClose will still try and write to a closed file - which instead of re-opening the file will now throw this exception?

@ghost
Copy link

ghost commented Aug 1, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@ndeloof
Copy link
Contributor Author

ndeloof commented Aug 1, 2016

@jtnord what you describe is what happens on OSX : as slave dir has been deleted, stream fails to get re-opened. This PR is just a workaround to limit impact, actual fix would require to ensure every component has logged what it needs before closing the log. Anyway the last step is to delete the log, so not sure this would benefit end-user :P

@oleg-nenashev oleg-nenashev added the needs-jira-issue A JIRA issue should be created for this PR. It is usually needed for the LTS backporting process label Aug 1, 2016
@oleg-nenashev
Copy link
Member

From what I see the only difference between old and new classes is appendOnNextOpen, which is always false in the case of the second implementation. IMO a simple refactoring of ReopenableFileOutputStream to a base class and two implementations should allow avoiding code dup.

@ndeloof
Copy link
Contributor Author

ndeloof commented Aug 1, 2016

@oleg-nenashev code indeed is very similar but ReopenableFileOutputStream intent is wrong : letting you re-open the stream without control on who is responsible to close it is source for file leaks. So I prefer to mark this as deprecated to later remote it, vs create a common ancestor that won't make much sense after removal.

@ndeloof ndeloof removed the needs-jira-issue A JIRA issue should be created for this PR. It is usually needed for the LTS backporting process label Aug 1, 2016
@recampbell recampbell changed the title don’t rely on ReopenableFileOutputStream [JENKINS-37098] don’t rely on ReopenableFileOutputStream Aug 1, 2016
@@ -37,8 +37,9 @@
* and then keep writing.
*
* @author Kohsuke Kawaguchi
* @deprecated due to risk for file leak
Copy link
Member

Choose a reason for hiding this comment

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

Link to the alternative (RewindableFileOutputStream I guess)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't an alternative, but a subset of what ReopenableFileOutputStream intended to do.

@jtnord
Copy link
Member

jtnord commented Aug 4, 2016

🐝 I think there is still an issue in the core that causes someone to attempt to log after a log has been closed() - this is currently causes ephemeral cloud slaves to blow up when they are removed on windows, and this should fix it - but as we can now delete the directory (whereas before the delete of the directory would fail as there where open handles - now the callback that wrote to the log will throw an IOException when attempting to write to the log that it has infact closed.) So please raise a JIRA for a follow up to cover this case.

@@ -137,7 +136,7 @@

public SlaveComputer(Slave slave) {
super(slave);
this.log = new ReopenableRotatingFileOutputStream(getLogFile(),10);
this.log = new RewindableFileOutputStream(getLogFile());
Copy link
Member

@jtnord jtnord Aug 4, 2016

Choose a reason for hiding this comment

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

do we not still want some rolling here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes indeed, I forgot this one

@oleg-nenashev
Copy link
Member

LGTM 🐝
Retriggering the build due to FindBugs change in the master

ReopenableFileOutputStream introduces file-leaks (detected on windows) when channel onClose writes on already closed log, and breaks when computer tries to delete the slave’s log directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-reviews Complex change, which would benefit from more eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants