podman icon indicating copy to clipboard operation
podman copied to clipboard

Podman 2.0.3 could not start a detached container on Jenkins slave

Open laminy opened this issue 6 years ago • 5 comments

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description I try to start podman rootless on Jenkins slave (vm). When I use podman run -d .., it crashes at startup with permission denied. But when I manually login on Jenkins slave via ssh with the same user as Jenkins slave works, and execute the same command from the same directory, it works.

Steps to reproduce the issue:

  1. Write Jenkins pipeline
node('linux') {
    sh "podman run --detach --name dntjzy9t_container private_registry/container:latest /bin/bash"
}
  1. Run Jenkins job
  2. Open build log and view error
+ podman run --detach --name dntjzy9t_container private_registry/container:latest /bin/bash
Error: container_linux.go:367: starting container process caused: process_linux.go:459: container init caused: process_linux.go:382: setting rlimits for ready process caused: error setting rlimit type 7: operation not permitted: OCI runtime permission denied error

Describe the results you received: Podman not started a new container

Describe the results you expected: Podman should start a new container in detached mode

Additional information you deem important (e.g. issue happens only occasionally): Jenkins home is the same as user home

Output of podman version:

Version:      2.0.3
API Version:  1
Go Version:   go1.13.4
Built:        Thu Jan  1 03:00:00 1970
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.15.0
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.19-1.el8.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.19, commit: 4726cba6f219c7479c28f0687868bd2ffe894869'
  cpus: 16
  distribution:
    distribution: '"rhel"'
    version: "8.1"
  eventLogger: file
  hostname: my.host.name
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 20003
      size: 1
    - container_id: 1
      host_id: 755360
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 20004
      size: 1
    - container_id: 1
      host_id: 755360
      size: 65536
  kernel: 4.18.0-147.5.1.el8_1.x86_64
  linkmode: dynamic
  memFree: 57828933632
  memTotal: 67379601408
  ociRuntime:
    name: runc
    package: runc-1.0.0-145.rc91.git24a3cf8.el8.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.2-dev'
  os: linux
  remoteSocket:
    path: /tmp/run-20004/podman/podman.sock
  rootless: true
  slirp4netns:
    executable: /bin/slirp4netns
    package: slirp4netns-1.1.4-1.el8.x86_64
    version: |-
      slirp4netns version 1.1.4
      commit: b66ffa8e262507e37fca689822d23430f3357fe8
      libslirp: 4.2.0
      SLIRP_CONFIG_VERSION_MAX: 2
  swapFree: 0
  swapTotal: 0
  uptime: 8h 2m 29.23s (Approximately 0.33 days)
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - registry.centos.org
  - docker.io
store:
  configFile: /home/jenkins/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /bin/fuse-overlayfs
      Package: fuse-overlayfs-1.1.2-1.el8.x86_64
      Version: |-
        fusermount3 version: 3.2.1
        fuse-overlayfs: version 1.1.0
        FUSE library version 3.2.1
        using FUSE kernel interface version 7.26
  graphRoot: /home/jenkins/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 1
  runRoot: /tmp/run-20004
  volumePath: /home/jenkins/.local/share/containers/storage/volumes
version:
  APIVersion: 1
  Built: 0
  BuiltTime: Thu Jan  1 03:00:00 1970
  GitCommit: ""
  GoVersion: go1.13.4
  OsArch: linux/amd64
  Version: 2.0.3

Package info (e.g. output of rpm -q podman or apt list podman):

podman-2.0.3-1.el8.x86_64

Additional environment details (AWS, VirtualBox, physical, etc.): VM (OpenStack)

cat ~/.config/containers/containers.conf

[containers]

 default_ulimits = [
   "nofile=262144:262144",
 ]

laminy avatar Jul 24 '20 21:07 laminy

This looks like you are attempting to set the ulimits for NOFILE to higher level then is allowed for the user to set. I think when you login directly pam_limits is being set, but when you run it in jenkens the process is getting different limits.

@giuseppe @mheon WDYT?

rhatdan avatar Jul 25 '20 11:07 rhatdan

I don't see the limits being explicitly say anywhere, unless they were in containers.conf?

On Sat, Jul 25, 2020, 07:16 Daniel J Walsh [email protected] wrote:

This looks like you are attempting to set the ulimits for NOFILE to higher level then is allowed for the user to set. I think when you login directly pam_limits is being set, but when you run it in jenkens the process is getting different limits.

@giuseppe https://github.com/giuseppe @mheon https://github.com/mheon WDYT?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/containers/podman/issues/7082#issuecomment-663843623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3AOCC7PRQXXQKF4NI2KN3R5K5KNANCNFSM4PHDC3NQ .

mheon avatar Jul 25 '20 14:07 mheon

Ahhh, missed the bit at the end where they were. Agree with Dan, probably set too high, higher than the current system allows.

On Sat, Jul 25, 2020, 10:28 Matthew Heon [email protected] wrote:

I don't see the limits being explicitly say anywhere, unless they were in containers.conf?

On Sat, Jul 25, 2020, 07:16 Daniel J Walsh [email protected] wrote:

This looks like you are attempting to set the ulimits for NOFILE to higher level then is allowed for the user to set. I think when you login directly pam_limits is being set, but when you run it in jenkens the process is getting different limits.

@giuseppe https://github.com/giuseppe @mheon https://github.com/mheon WDYT?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/containers/podman/issues/7082#issuecomment-663843623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3AOCC7PRQXXQKF4NI2KN3R5K5KNANCNFSM4PHDC3NQ .

mheon avatar Jul 25 '20 14:07 mheon

Limits from /etc/security directory. limits.conf has no uncommented lines

[root@pc /etc/security]# ls limits.d/
90-nofiles.conf
[root@pc /etc/security]# cat limits.d/90-nofiles.conf 
*          soft    nofile     262144
*          hard    nofile     262144

File /usr/share/containers/containers.conf was not modified after installation. File /etc/containers/containers.conf not exists.

I run ulimit -a: From ssh terminal as Jenkins user

[jenkins@pc ~]$ ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256904
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 262144
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256904
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Next run from Jenkins pipeine

node('linux') {
    sh "ulimit -a"  
}

and output

core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256904
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4096 ## <- this is **incorrect** limit
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256904
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Ok. I added limit to /etc/systemd/system/jenkins-agent.service and restart service

[root@pc /etc/systemd/system]# cat jenkins-agent.service 
[Service]
...
LimitNOFILE=262144
...

And execute pipeline once again

+ ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256904
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 262144 ## <- now correct limit
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256904
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Then verify limits inside container (it started!) from Jenkins pipeline

+ podman run --name dntjzy9t_container private_registry/container:latest ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256904
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 262144 ## <- limits also passed
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 32768
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Good. And the last check from pipeline:

node('linux') {
    sh "podman run -d --name dntjzy9t_container private_registry/container:latest tail -f /dev/null"
    sh "podman exec -i dntjzy9t_container ls"
    sh "podman rm -f dntjzy9t_container"
}

and it works!

+ podman run -d --name dntjzy9t_container private_registry/container:latest tail -f /dev/null
39c44844ab203cbb0df29d2241100354803b7b453ed62f62d2f9d595848c60eb
[Pipeline] sh
+ podman exec -i dntjzy9t_container ls
bin
boot
...
[Pipeline] sh
+ podman rm -f dntjzy9t_container
39c44844ab203cbb0df29d2241100354803b7b453ed62f62d2f9d595848c60eb

Ok. But how about accessing such container from ssh terminal?

  1. From pipeline I started a container
node('linux') {
    sh "podman run --detach --name dntjzy9t_container private_registry/container:latest tail -f /dev/null"
}
  1. login via ssh to agent host as Jenkins user and try access to container
[jenkins@pc ~]$ podman exec -i dntjzy9t_container ls
Error: exec failed: container_linux.go:367: starting container process caused: transport endpoint is not connected: OCI runtime error

Maybe error because container started as child process from linux service (via systemd)? Thank You to help me solving this issue in my configuration.

laminy avatar Jul 26 '20 09:07 laminy

Yes when you login to a user session via ssh you are executing pam_limits which reads /etc/security/limits.conf and sets it up for the user account.

If you login to the system as root and su to the user, or launch the user process via systemd, then the pam_limits is not executed and the session will have different limits.

rhatdan avatar Jul 26 '20 12:07 rhatdan