-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Container detection fails on cgroup v2 devices #1592
Comments
This detection issue seems to come from an upstream dependency, namely https://github.com/genuinetools/bpfd/blob/master/proc/proc.go. GetContainerID(...) tries to glance a container identifier from cgroup path information and the way cgroup paths are detected differs between the v1 multiple hierarchies and the unified v2 hierarchy. |
Exactly, the question is how this detection can get fixed. Either in the dependency upstream or in Kaniko itself. Does a process running in a Docker container on a system with cgroup v2 have a way to detect that it's running in a container? Podman, as an example that works, explicitly declares it by assigning the environment variable |
A closer look at a container's In consequence, there doesn't seem to be any chance to fix the detection upstream, at least not for stock default Docker configurations. So there's probably only |
Currently I don't see any other option, but I might be missing something... |
There actually is one sign that might be useful to container detection, albeit without specifics as to which engine is used: when using cgroups v2 with the namespace boundaries then the cgroup2 "root" has a Would that be sufficient for Kaniko? Note bene: looking at the cgroup namespace itself doesn't help much, unless the container had been started with "host:pid", so there is no chance of reckoning whether this is the initial cgroup namespace or not. See also:
|
Revert after [0] is fixed [0] GoogleContainerTools/kaniko#1592
I had a look at how systemd does it, the main code is here. Among other things, it checks if specific files exist on the filesystem. |
This is a temporary workaround that enables kaniko to run on cgroup v2 enabled hosts. Due to an upstream issue, kaniko fails to detect that it is indeed being run from a container. Solution introduced here is to force kaniko to run regardless. ref: GoogleContainerTools/kaniko#1592 [skip ci]
I confirm the |
I've pushed a PR on upstream genuinetools/bpfd#19, however I noticed that package last activity was on 2019, so there's a chance it's not merged soon, @tejal29 should I backport the fix to https://github.com/GoogleContainerTools/kaniko/blob/master/vendor/github.com/genuinetools/bpfd/proc/proc.go as well to fix this on our side? |
@klausenbusk @ejose19 the systemd approach is a "good weather" approach that surely covers over 90% of all use-cases, but that percentage will be slowly reducing... IMO As long as Kaniko provides the flag Additional informationThe file Podman approach is much better, since it's the container runtime providing runtime information (therefore the file appears in the temporary directory Container images being built with buildah don't provide the file |
Is a release with this already planned? |
I'd also be interested, altough in the meantime I believe you could get away with using the latest stable-ish build from executor's GCP index. |
@pschichtel @wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf there's meanwhile an issue requesting a new release, you can react to it to raise its visibility: #1740 |
GoogleContainerTools/kaniko#1592 .... bump version [skip ci]
GoogleContainerTools/kaniko#1592 .... bump version [skip ci]
Actual behavior
Kaniko fails to detect that it's running in a Docker container when not run on a system using cgroup v2.
Error message:
This issue can be reproduced on a Debian Testing/Bullseye (default using cgroup v2) installation and on an ArchLinux installation using cgroup v2.
This issue originates from the way genuinetools/bpfd/proc detects if running in a Docker container or not. On Debian Stable/Buster (default using cgroup v1) and Archlinux using cgroup v1
Expected behavior
Kaniko detects the container runtime properly and doesn't report any issue.
To Reproduce
A system with cgroup v2 is needed to reproduce the issue.
Steps to reproduce the behavior (lines starting with
$
are to be run on the host, lines starting with#
are to be run in the container):$ docker run --rm -ti --entrypoint "" gcr.io/kaniko-project/executor:v1.5.1-debug sh
# echo "FROM alpine:latest" > Dockerfile
# /kaniko/executor --dockerfile Dockerfile --destination /dev/null
Additional Information
Independent of Dockerfile, tested with different ones.
Independent of context (tested on contexts without copying any file)
gcr.io/kaniko-project/executor:v1.5.1-debug, sha256:e00dfdd4a44097867c8ef671e5a7f3e31d94bd09406dbdfba8a13a63fc6b8060
Triage Notes for the Maintainers
--cache
flagThe text was updated successfully, but these errors were encountered: