podman icon indicating copy to clipboard operation
podman copied to clipboard

Additional Stores permissions issue on NFS share

Open ajyounge opened this issue 5 years ago • 10 comments

/kind bug

Description

I am trying to use the additional stores feature in Podman, as documented in https://www.redhat.com/sysadmin/image-stores-podman. It seems there is some issue with the locks not being generated and/or used properly. Is it possible I am just missing some permissions setting for the locks? I tried to manually touch the lock file but it did not help much. The /projects directory is mounted via NFS and this is on an RHEL8.4 aarch64 system.

Steps to reproduce the issue:

$ mkdir /projects/containers/add-store2
$ vi ~/.config/containers/storage.conf
$ cat ~/.config/containers/storage.conf
[storage]
graphroot = "/tmp/my-user-graphroot"
driver = "overlay"

[storage.options]
mount_program = "/usr/bin/fuse-overlayfs"
additionalimagestores = ["/projects/containers/add-store2"]

$ podman images
Error: error opening "/projects/containers/add-store2/overlay-images/images.lock": no such file or directory
$ chmod -R a+rx /projects/containers/add-store2
$ podman images
Error: error opening "/projects/containers/add-store2/overlay-images/images.lock": no such file or directory
$ podman info
Error: error opening "/projects/containers/add-store2/overlay-images/images.lock": no such file or directory
$ # I'll try to create the sub-dir and touch the images lock file
$ mkdir /projects/containers/add-store2/overlay-images
$ touch /projects/containers/add-store2/overlay-images/images.lock
$ podman images
Error: error retrieving label for image "e5df02c436858279600da64c8614547753be6baf6ef4fee082e9c76e2762151f": you may need to remove the image to resolve the error: error opening "/projects/containers/add-store2/overlay-layers/layers.lock": no such file or directory
$ chmod -R a+rx /projects/containers/add-store2
$ podman images
Error: error retrieving label for image "e5df02c436858279600da64c8614547753be6baf6ef4fee082e9c76e2762151f": you may need to remove the image to resolve the error: error opening "/projects/containers/add-store2/overlay-layers/layers.lock": no such file or directory
$ # I'll also manually create the layers lock file
$ mkdir /projects/containers/add-store2/overlay-layers
$ touch /projects/containers/add-store2/overlay-layers/layers.lock
$ podman images
REPOSITORY                       TAG         IMAGE ID      CREATED       SIZE
registry.access.redhat.com/ubi8  latest      eb537cb8064c  5 weeks ago   267 MB
quay.io/centos/centos            8           a0477e85b8ae  9 months ago  256 MB
docker.io/library/centos         7           e5df02c43685  9 months ago  310 MB
$ podman --root /projects/containers/add-store2  pull fedora
Error: lock "/projects/containers/add-store2/overlay-images/images.lock" is not a read-only lock

Describe the results you received:

I am getting the following error when trying to use additional stores: Error: error opening "/projects/containers/add-store2/overlay-images/images.lock": no such file or directory

When I create the images.lock and layers.lock files manually, I still get the following error wile trying to use the additional store: Error: lock "/projects/containers/add-store2/overlay-images/images.lock" is not a read-only lock

Describe the results you expected:

That podman --root /projects/containers/add-store2 pull fedora would work.

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

Output of podman version:

$ podman version
Version:      3.2.3
API Version:  3.2.3
Go Version:   go1.15.7
Built:        Tue Jul 27 01:30:08 2021
OS/Arch:      linux/arm64

Output of podman info --debug:

NOTE: hostname removed, username faked to "my-user", and $UID changed to fake "12345" for security reasons.

$ podman info --debug
host:
  arch: arm64
  buildahVersion: 1.21.3
  cgroupControllers: []
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: |-
      conmon-2.0.22-3.module+el8.3.1+9857+68fb1526.aarch64
      conmon-2.0.29-1.module+el8.4.0+11822+6cc1e7d7.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.29, commit: 6c00f196e70c84a22f57f61792e879cb37b029ea'
  cpus: 112
  distribution:
    distribution: '"rhel"'
    version: "8.4"
  eventLogger: file
  hostname: ##REMOVED##
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 12345
      size: 1
    - container_id: 1
      host_id: 200000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 12345
      size: 1
    - container_id: 1
      host_id: 200000
      size: 65536
  kernel: 4.18.0-240.15.1.el8_3.aarch64
  linkmode: dynamic
  memFree: 267904942080
  memTotal: 273825923072
  ociRuntime:
    name: runc
    package: |-
      runc-1.0.0-70.rc92.module+el8.3.1+9857+68fb1526.aarch64
      runc-1.0.0-74.rc95.module+el8.4.0+11822+6cc1e7d7.aarch64
    path: /usr/bin/runc
    version: |-
      runc version spec: 1.0.2-dev
      go: go1.15.13
      libseccomp: 2.5.1
  os: linux
  remoteSocket:
    path: /run/user/12345/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_NET_RAW,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-1.1.8-1.module+el8.3.1+9857+68fb1526.aarch64
      slirp4netns-1.1.8-1.module+el8.4.0+11822+6cc1e7d7.aarch64
    version: |-
      slirp4netns version 1.1.8
      commit: d361001f495417b880f20329121e3aa431a8f90f
      libslirp: 4.3.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.1
  swapFree: 4294901760
  swapTotal: 4294901760
  uptime: 21h 48m 29.1s (Approximately 0.88 days)
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /home/my-user/.config/containers/storage.conf
  containerStore:
    number: 7
    paused: 0
    running: 0
    stopped: 7
  graphDriverName: overlay
  graphOptions:
    overlay.imagestore: /projects/containers/add-store2
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: |-
        fuse-overlayfs-1.3.0-2.module+el8.3.1+9857+68fb1526.aarch64
        fuse-overlayfs-1.6-1.module+el8.4.0+11822+6cc1e7d7.aarch64
      Version: |-
        fusermount3 version: 3.2.1
        fuse-overlayfs: version 1.6
        FUSE library version 3.2.1
        using FUSE kernel interface version 7.26
  graphRoot: /tmp/my-user-graphroot
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 3
  runRoot: /run/user/12345/containers
  volumePath: /tmp/my-user-graphroot/volumes
version:
  APIVersion: 3.2.3
  Built: 1627371008
  BuiltTime: Tue Jul 27 01:30:08 2021
  GitCommit: ""
  GoVersion: go1.15.7
  OsArch: linux/arm64
  Version: 3.2.3

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

$ rpm -q podman
podman-2.2.1-7.module+el8.3.1+9857+68fb1526.aarch64
podman-3.2.3-0.10.module+el8.4.0+11989+6676f7ad.aarch64

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

YES

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

This is running on a Marvell ThunderX2 aarch64 system with RHEL8.4.

$ uname -a
Linux ##REMOVED## 4.18.0-240.15.1.el8_3.aarch64 #1 SMP Wed Feb 3 03:16:05 EST 2021 aarch64 aarch64 aarch64 GNU/Linux

ajyounge avatar Sep 08 '21 16:09 ajyounge

I think you need to create the additional store as the root user, so it can use any other additional ID.

You'll also need to create the storage before setting it in the additionalimagestores, otherwise the storage tries to use it before it is ready.

giuseppe avatar Sep 09 '21 08:09 giuseppe

Ok I tried to create a new directory /projects/containers/add-store3 as a privileged user and also ran chmod -R a+rx /projects/containers/add-store3 but I still see that Podman doesn't know see the lock. Should I be manually creating these or would Podman presumably create them?

$ ls -l /projects/containers
total 68144
drwxrwxr-x  9 my-user my-user        4096 Sep  8 09:49 add-store2
drwxr-xr-x  2 root    root           4096 Sep  9 08:22 add-store3
...
$ ls -l add-store3
total 0
$ cat ~/.config/containers/storage.conf
[storage]
graphroot = "/tmp/my-user-graphroot"
driver = "overlay"

[storage.options]
mount_program = "/usr/bin/fuse-overlayfs"
additionalimagestores = ["/projects/containers/add-store3"]
$ podman images
Error: error opening "/projects/containers/add-store3/overlay-images/images.lock": no such file or directory

ajyounge avatar Sep 09 '21 14:09 ajyounge

@ajyounge is this issue still relevant?

Have you tried to create the entire storage with podman --root /projects/containers/add-store3 pull foo ?

giuseppe avatar Sep 27 '21 08:09 giuseppe

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Oct 28 '21 00:10 github-actions[bot]

Since we have had no info in a month, I am going to close. Reopen if this is still an issue and you have more info.

rhatdan avatar Oct 29 '21 14:10 rhatdan

I can confirm that either created as root or as a user, permissions are too restrictive for another user to use it in additionalimagestores. Is it possible to specify which permissions are used when creating the image store? And when updating it?

volgar1x avatar Mar 31 '22 11:03 volgar1x

you can do it with force_mask = "shared" in storage.conf. You also need to use a mount program and chown the storage directory itself

giuseppe avatar Mar 31 '22 14:03 giuseppe

It does not seem to work with podman 3.4.4. Here's how I proceeded:

  1. run as root: install -d -o drone -g drone -m 755 /data/containers/images
  2. configured /home/drone/.config/containers/storage.conf like this:
[storage]
driver = "overlay"
graphroot = "/data/containers/images"

[storage.options.overlay]
mount_program = "/usr/bin/fuse-overlayfs"
force_mask = "shared"
  1. run as drone: podman pull alpine:3.14\
  2. checked permissions with ls:
drone@home:~> ls -al /data/containers/images/
total 37
drwxr-xr-x 9 drone drone 11 Mar 31 17:41 .
drwxr-xr-x 3 root  root   3 Mar 31 17:41 ..
drwx------ 2 drone drone  4 Mar 31 17:41 libpod
drwx------ 2 drone drone  2 Mar 31 17:41 mounts
drwx------ 4 drone drone  5 Mar 31 17:41 overlay
drwx------ 2 drone drone  3 Mar 31 17:41 overlay-containers
drwx------ 3 drone drone  5 Mar 31 17:41 overlay-images
drwx------ 2 drone drone  5 Mar 31 17:41 overlay-layers
-rw-r--r-- 1 drone drone 64 Mar 31 17:41 storage.lock
drwx------ 2 drone drone  2 Mar 31 17:41 tmp
-rw-r--r-- 1 drone drone  0 Mar 31 17:41 userns.lock

Same result with this config:

[storage]
driver = "overlay"
graphroot = "/data/containers/images"

[storage.options]
force_mask = 0o755

[storage.options.overlay]
mount_program = "/usr/bin/fuse-overlayfs"
force_mask = "shared"

Should I wait for openSUSE Tumbleweed to update to podman 4.0.2 ?

Thanks so much for your help though!

volgar1x avatar Mar 31 '22 17:03 volgar1x

are the files under /data/containers/images/overlay stored with the correct mask?

For the upper directories you'll need to manually tweak the permission masks with chmod -R 755 /data/containers/images

giuseppe avatar Apr 01 '22 07:04 giuseppe

Nope, I still have to manually to chmod -R 755 $REPO every time an image is built. Here is the commands I ran:

  1. as root:
root@home:~> chmod -R 755 /data/containers/images
  1. as drone:
drone@home:~> podman pull python:3-alpine
Resolving "python" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/library/python:3-alpine...
Getting image source signatures
Copying blob 4a0d1c29879f done
Copying blob 3cfa42da295b done
Copying blob 827b8c659b41 done
Copying blob 94213b84cbcb done
Copying blob 80fa7f07ec7b done
Copying config 32e522828c done
Writing manifest to image destination
Storing signatures
32e522828c75d24b72ac0f7f5f35f1a69601298f92ef33c6e628b2ec03acdadc

drone@home:~> ls -al /data/containers/images/overlay
total 25
drwxr-xr-x 9 drone drone 10 Apr  1 08:25 .
drwxr-xr-x 9 drone drone 11 Apr  1 08:24 ..
-rwxr-xr-x 1 drone drone  4 Apr  1 08:25 .has-mount-program
drwx------ 5 drone drone  7 Apr  1 08:25 25c417ad3a322d0bd728e6076ccc38f09215fb549a5c3bd037017d236513d356
drwx------ 5 drone drone  7 Apr  1 08:25 863937bbfaf9fda2ad4fe11d67c882f747f183f41ca04c3843a3eef52971630a
drwx------ 6 drone drone  7 Apr  1 08:25 9d982e0ac7aee7e383989508c9b7175fae67221f80323067252a0442c632a67f
drwxr-xr-x 6 drone drone  7 Apr  1 08:24 b94faa1881514a249125e08336f2ffa20ba30d12ddea28988bbf631fb2d0231b
drwx------ 5 drone drone  7 Apr  1 08:25 b985a3d3eef4c0d3de3b5ea3577909ea5d448bb7ebe09cb9d41233e0a08a1bbb
drwx------ 5 drone drone  7 Apr  1 08:25 e6a77c2c233088e2fd5c7f96347899e16c6075c7a7cc4640d7709d97f051a087
drwxr-xr-x 2 drone drone  8 Apr  1 08:25 l

drone@home:~> ls -al /data/containers/images/overlay-images
total 41
drwxr-xr-x 4 drone drone    6 Apr  1 08:25 .
drwxr-xr-x 9 drone drone   11 Apr  1 08:24 ..
drwx------ 2 drone drone    7 Apr  1 08:25 32e522828c75d24b72ac0f7f5f35f1a69601298f92ef33c6e628b2ec03acdadc
drwxr-xr-x 2 drone drone    7 Apr  1 08:24 cc3d11fa2d52fe76eaea8c4b53341bb18d818370191844bbfbc3a7feb3ff092c
-rw------- 1 drone drone 3844 Apr  1 08:25 images.json
-rwxr-xr-x 1 drone drone   64 Apr  1 08:25 images.lock

volgar1x avatar Apr 01 '22 08:04 volgar1x