jenkinsci / jenkinsci/docker-workflow-plugin
[JENKINS-75139] Docker workflow plugin gets wrong containerId
- Dominant language
- Java
- Stars
- 527
- Forks
- 422
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
Running Jenkins in rke with RHEL9 nodes, with cgroupv2, the docker plugin gets the wrong containerId from /proc/1/selfmount. Rke creates a "pause" container for each pod, and the jenkins-agent container has the containerId of the pause container in /proc/1/selfmount: https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L364 and https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L342 - this hostname mount comes from the pause container and not the jenkins container.
The way the plugin has to get the containerId is unreliable for cgroupv2
This means that the plugin can't find the volumes used by the jenkins agent container, and will fail to mount them: https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L188-L190 . Because of these two lines, I can't even pass the flag "--volumes-from" to the docker args when running the instruction .inside(dockerArgs), because the plugin tries to mount the workspace path from the host, which does not make sense since the workspace only exists in the jenkins container
---
Originally reported by gfigueira, imported from: Docker workflow plugin gets wrong containerId
Raw content of original issue
Running Jenkins in rke with RHEL9 nodes, with cgroupv2, the docker plugin gets the wrong containerId from /proc/1/selfmount. Rke creates a "pause" container for each pod, and the jenkins-agent container has the containerId of the pause container in /proc/1/selfmount: https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L364 and https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L342 - this hostname mount comes from the pause container and not the jenkins container.
The way the plugin has to get the containerId is unreliable for cgroupv2
This means that the plugin can't find the volumes used by the jenkins agent container, and will fail to mount them: https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L188-L190 . Because of these two lines, I can't even pass the flag "--volumes-from" to the docker args when running the instruction <image>.inside(dockerArgs), because the plugin tries to mount the workspace path from the host, which does not make sense since the workspace only exists in the jenkins container
- environment:
RHEL9, Rocky9
Contributor guide
Assessment
This issue has not been assessed yet.