Skip to content
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

mountPropagation: Bidirectional does not work in Kubernetes Pod Yaml #13322

Closed
rudolfvesely opened this issue Feb 23, 2022 · 1 comment
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@rudolfvesely
Copy link

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

/kind bug

Description

mountPropagation: Bidirectional does not work in Kubernetes Pod Yaml. rshared when executing podman directly works fine.

Steps to reproduce the issue:

  • as non-root user:
mkdir /tmp/from
podman unshare umount /tmp/from # if bind mounted previously
podman unshare mount --make-shared --bind /tmp/from /tmp/from
podman run --cap-add SYS_ADMIN --rm --volume=/tmp/from:/to:rshared -d --name=mounting debian sh -c 'mkdir /to; mount -t tmpfs tmpfs /to; date > /to/myfile; sleep infinity'
podman unshare ls -l /tmp/from
  • this is good:
total 4
-rw-r--r-- 1 root root 29 Feb 23 11:55 myfile
  • as non-root user:
---
apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
    - name: app
      image: docker.io/library/debian
      command: ['sh']
      args:
        - -c
        - 'mount -t tmpfs tmpfs /mnt; date > /mnt/myfile; sleep infinity'
      volumeMounts:
        - name: mydata
          mountPath: /mnt
          mountPropagation: Bidirectional
      securityContext:
        capabilities:
          add:
          - CAP_SYS_ADMIN
  volumes:
    - name: mydata
      hostPath:
        type: Directory
        path: /tmp/from
mkdir /tmp/from
podman unshare umount /tmp/from # if bind mounted previously
podman unshare mount --make-shared --bind /tmp/from /tmp/from
podman play kube file.yml
  • this is good:
podman exec mypod-app ls -l /mnt
total 4
-rw-r--r-- 1 root root 29 Feb 23 12:05 myfile
  • this is good:
podman exec mypod-app sh -c 'mount | grep "tmpfs.*mnt"'
tmpfs on /mnt type tmpfs (rw,relatime,uid=1234,gid=1234,inode64)
  • this is wrong:
podman unshare ls -l /tmp/from
total 0

Describe the results you received:

The file "myfile" should be listed.

Additional information you deem important (e.g. issue happens only occasionally):

Always

Output of podman version:

Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.17.5
Built:        Thu Jan  1 00:00:00 1970
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.23.1
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: 'conmon: /usr/bin/conmon'
    path: /usr/bin/conmon
    version: 'conmon version 2.0.25, commit: unknown'
  cpus: 16
  distribution:
    distribution: debian
    version: unknown
  eventLogger: journald
  hostname: ip-172-16-1-62
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.15.0-3-cloud-amd64
  linkmode: dynamic
  logDriver: journald
  memFree: 42368770048
  memTotal: 43133235200
  ociRuntime:
    name: crun
    package: 'crun: /usr/bin/crun'
    path: /usr/bin/crun
    version: |-
      crun version 0.17
      commit: 0e9229ae34caaebcb86f1fde18de3acaf18c6d9a
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  remoteSocket:
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: 'slirp4netns: /usr/bin/slirp4netns'
    version: |-
      slirp4netns version 1.0.1
      commit: 6a7b16babc95b6a3056b33fb45b74a6f62262dd4
      libslirp: 4.6.1
  swapFree: 0
  swapTotal: 0
  uptime: 3m 20.16s
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries: {}
store:
  configFile: /home/admin/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/admin/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 0
  runRoot: /run/user/1000/containers
  volumePath: /home/admin/.local/share/containers/storage/volumes
version:
  APIVersion: 3.4.4
  Built: 0
  BuiltTime: Thu Jan  1 00:00:00 1970
  GitCommit: ""
  GoVersion: go1.17.5
  OsArch: linux/amd64
  Version: 3.4.4

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

podman/testing,now 3.4.4+ds1-1 amd64 [installed]

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

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

AWS

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Feb 23, 2022
@giuseppe
Copy link
Member

PR here: #13320

@Luap99 Luap99 closed this as completed Feb 23, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

3 participants