JENKINS-64608: detect running in container by ENV to allow detection independent of cgroup version#241
Closed
gmasil wants to merge 3 commits intojenkinsci:masterfrom
gmasil:feature/JENKINS-64608-detect-running-in-container-by-env
Closed
JENKINS-64608: detect running in container by ENV to allow detection independent of cgroup version#241gmasil wants to merge 3 commits intojenkinsci:masterfrom gmasil:feature/JENKINS-64608-detect-running-in-container-by-env
gmasil wants to merge 3 commits intojenkinsci:masterfrom
gmasil:feature/JENKINS-64608-detect-running-in-container-by-env
Conversation
…independent of cgroup version
…ck to cgroup evaluation
…4608-detect-running-in-container-by-env
|
@rsandell What is the blocking factor making this PR not being merged? I would like to help working on this PR. |
|
Either
If there is no action on this, a lot of human capital is going to waste diagnosing this issue. |
|
I just noticed that I can discover the container ID inside |
Author
|
@jglick Today I was setting up my Jenkins from scratch and I gave your plugin a shot: works perfectly fine under cgroups v2! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using cgroup v2 the docker-workflow-plugin cannot determine if it is running inside a container by checking
/proc/self/cgroupanymore.JIRA: https://issues.jenkins.io/browse/JENKINS-64608
I suggest using an environment variable telling the plugin if Jenkins is running inside a container, so we are independent of cgroup version. I called the env var
JENKINS_RUNNING_IN_CONTAINERwhich has to be set totrue. This could be done in Jenkins' Dockerfile, so no configuration has to be changed for example in docker-compose or kubernetes. The container ID is resolved by taking a look into/etc/hostname, which is only giving the short container id, it can be discussed if that could face a problem.Before I provide tests I would like to get some feedback if the general idea is okay or not.
Background
I recently updated to Debian 11 (providing cgroup v2 support) which broke my Jenkins setup, so I quickly needed a fix. I am using this patched plugin right now in my personal Jenkins and it is working perfectly fine.
Addendum
Here the question is asked how to obtain docker info when cgroup v2 is enabled, still unanswered:
https://stackoverflow.com/questions/68816329/how-to-get-docker-container-id-from-within-the-container-with-cgroup-v2
Checklist