docker-workflow-plugin icon indicating copy to clipboard operation
docker-workflow-plugin copied to clipboard

JENKINS-63628: Handle "process leaked file descriptors" issue

Open EricHripko opened this issue 6 months ago • 3 comments

This PR proposes a fix for the occasional Process leaked file descriptors issue with this plugin. Please see my comment for the research into this failure and any relevant prior art. It should fix JENKINS-63628.

Testing done

I've added unit tests for this change, and these passed locally ✅

The tests in the current repo are system/integration tests, but (given the nature of the issue) I could not write a system test that reliably reproduces this. This is why this PR adds mockito dependency and a pair of unit tests to verify this functionality.

Submitter checklist

  • [x] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • [x] Ensure that the pull request title represents the desired changelog entry
  • [X] Please describe what you did
  • [X] Link to relevant issues in GitHub or Jira
  • [X] Link to relevant pull requests, esp. upstream and downstream changes
  • [X] Ensure you have provided tests that demonstrate the feature works or the issue is fixed

EricHripko avatar Jun 05 '25 08:06 EricHripko

Hi @jglick! I see you contributed here recently - would you be able to help with reviewing this plugin? Let me know if I should poke someone else instead/too.

EricHripko avatar Jun 12 '25 12:06 EricHripko

I do not maintain this plugin; I am not sure if anyone does. My standing advice (as the principal original author) is to not use it.

jglick avatar Jun 24 '25 17:06 jglick

Anyway this does not look like the right fix. https://github.com/jenkinsci/jenkins/blob/47d10476078ff6fc938bfd81c2679fde7c4df220/core/src/main/java/hudson/Proc.java#L355-L356 ought to be deleted (a warning in the system log should suffice); but the root problem sounds like something mistaken in this plugin that does indeed leak file handles.

jglick avatar Jun 24 '25 17:06 jglick

@jglick thank you for clarifying - do you think it's still worth fixing this issue or should I abandon the attempts to do so?

If I understand the plugin code correctly, it intentionally spawns a container/process in the background so that it outlives the Proc invocation: https://github.com/jenkinsci/docker-workflow-plugin/blob/a73f881d9232e98f0e1f04cac45358ece361616f/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L200 Follow up pipeline steps seem to be then executed via an equivalent to docker exec in said container.

EricHripko avatar Jun 25 '25 16:06 EricHripko

I would suggest closing this and deleting the core code I pointed out.

jglick avatar Jul 07 '25 20:07 jglick

Thank you for confirming! Will pursue other options 👍

EricHripko avatar Oct 13 '25 16:10 EricHripko