storage icon indicating copy to clipboard operation
storage copied to clipboard

rootless overlay support check fails if configured mount_program in /etc/containers/storage.conf is not in $PATH

Open mrinaldhillon opened this issue 3 years ago • 5 comments

Description Rootless buildah info fails overlay support check if the mount_program is installed at a non-default path and it's absolute path is configured in /etc/containers/storage.conf. buildah info passes if the mount_program's is found in $PATH or its absolute path is configured in $HOME/.config/containers/storage.conf or is set from the command line flag --storage-opt .

Reproducible by installing fuse-overlayfs at a non-default path - /home/ubuntu/bin/fuse-overlayfs and configure the same only in /etc/containers/storage.conf .

Steps to reproduce the issue:

  1. Install buildah from kubic repo without fuse-overlayfs
sudo buildah --debug info
{
    "debug": {
        "buildah version": "1.21.3",
        "compiler": "gc",
        "git commit": "",
        "go version": "go1.15.2"
    },
    "host": {
        "CgroupVersion": "v1",
        "Distribution": {
            "distribution": "ubuntu",
            "version": "20.04"
        },
        "MemFree": 8771399680,
        "MemTotal": 12557430784,
        "OCIRuntime": "crun",
        "SwapFree": 0,
        "SwapTotal": 0,
        "arch": "amd64",
        "cpus": 12,
        "hostname": "focal",
        "kernel": "5.4.0-94-generic",
        "os": "linux",
        "rootless": false,
        "uptime": "1h 41m 23.98s (Approximately 0.04 days)"
    },
    "store": {
        "ContainerStore": {
            "number": 0
        },
        "GraphDriverName": "overlay",
        "GraphOptions": [
            "overlay.mountopt=nodev,metacopy=on"
        ],
        "GraphRoot": "/var/lib/containers/storage",
        "GraphStatus": {
            "Backing Filesystem": "extfs",
            "Native Overlay Diff": "false",
            "Supports d_type": "true",
            "Using metacopy": "true"
        },
        "ImageStore": {
            "number": 0
        },
        "RunRoot": "/run/containers/storage"
    }
}

ubuntu@focal:~$ which fuse-overlayfs
ubuntu@focal:~$

ubuntu@focal:~$ buildah --debug info
kernel does not support overlay fs: unable to create kernel-style whiteout: operation not permitted
WARN[0000] failed to shutdown storage: "kernel does not support overlay fs: unable to create kernel-style whiteout: operation not permitted"
ERRO[0000] exit status 125
  1. Download fuse-overlayfs static binary, and set mount_program in /etc/containers/storage.conf
ubuntu@focal:~$ wget https://github.com/containers/fuse-overlayfs/releases/download/v1.8/fuse-overlayfs-x86_64 -O /home/ubuntu/bin/fuse-overlayfs && chmod a+x /home/ubuntu/bin/fuse-overlayfs
ubuntu@focal:~$ sudo sed -i 's/#mount_program.*/mount_program\ =\ "\/home\/ubuntu\/bin\/fuse-overlayfs"/' /etc/containers/storage.conf

ubuntu@focal:~$ sudo buildah --log-level=trace info --debug
DEBU[0000] [graphdriver] trying provided driver "overlay"
DEBU[0000] overlay: mount_program=/home/ubuntu/bin/fuse-overlayfs
DEBU[0000] backingFs=extfs, projectQuotaSupported=false, useNativeDiff=false, usingMetacopy=false
{
    "debug": {
        "buildah version": "1.21.3",
        "compiler": "gc",
        "git commit": "",
        "go version": "go1.15.2"
    },
    "host": {
        "CgroupVersion": "v1",
        "Distribution": {
            "distribution": "ubuntu",
            "version": "20.04"
        },
        "MemFree": 8762142720,
        "MemTotal": 12557430784,
        "OCIRuntime": "crun",
        "SwapFree": 0,
        "SwapTotal": 0,
        "arch": "amd64",
        "cpus": 12,
        "hostname": "focal",
        "kernel": "5.4.0-94-generic",
        "os": "linux",
        "rootless": false,
        "uptime": "3h 0m 8.78s (Approximately 0.12 days)"
    },
    "store": {
        "ContainerStore": {
            "number": 0
        },
        "GraphDriverName": "overlay",
        "GraphOptions": [
            "overlay.mount_program=/home/ubuntu/bin/fuse-overlayfs",
            "overlay.mountopt=nodev,metacopy=on"
        ],
        "GraphRoot": "/var/lib/containers/storage",
        "GraphStatus": {
            "Backing Filesystem": "extfs",
            "Native Overlay Diff": "false",
            "Supports d_type": "true",
            "Using metacopy": "false"
        },
        "ImageStore": {
            "number": 0
        },
        "RunRoot": "/run/containers/storage"
    }
}
DEBU[0000] shutting down the store
  1. PASS: Rootless overlay check passes if mount_program in $PATH
ubuntu@focal:~$ PATH=$PATH:/home/ubuntu/bin buildah --debug info
{
    "debug": {
        "buildah version": "1.21.3",
        "compiler": "gc",
        "git commit": "",
        "go version": "go1.15.2"
    },
    "host": {
        "CgroupVersion": "v1",
        "Distribution": {
            "distribution": "ubuntu",
            "version": "20.04"
        },
        "MemFree": 8747040768,
        "MemTotal": 12557430784,
        "OCIRuntime": "crun",
        "SwapFree": 0,
        "SwapTotal": 0,
        "arch": "amd64",
        "cpus": 12,
        "hostname": "focal",
        "kernel": "5.4.0-94-generic",
        "os": "linux",
        "rootless": true,
        "uptime": "2h 50m 46.84s (Approximately 0.08 days)"
    },
    "store": {
        "ContainerStore": {
            "number": 0
        },
        "GraphDriverName": "overlay",
        "GraphOptions": [
            "overlay.mount_program=/home/ubuntu/bin/fuse-overlayfs"
        ],
        "GraphRoot": "/home/ubuntu/.local/share/containers/storage",
        "GraphStatus": {
            "Backing Filesystem": "extfs",
            "Native Overlay Diff": "false",
            "Supports d_type": "true",
            "Using metacopy": "false"
        },
        "ImageStore": {
            "number": 1
        },
        "RunRoot": "/run/user/1000/containers"
    }
}
  1. PASS: Rootless overlay check passes if mount_program set by command line flag --storage-opt.
ubuntu@focal:~$ which fuse-overlayfs
ubuntu@focal:~$

ubuntu@focal:~$ buildah --storage-driver=overlay --storage-opt="overlay.mount_program=/home/ubuntu/bin/fuse-overlayfs" info
{
    "host": {
        "CgroupVersion": "v1",
        "Distribution": {
            "distribution": "ubuntu",
            "version": "20.04"
        },
        "MemFree": 8754876416,
        "MemTotal": 12557430784,
        "OCIRuntime": "crun",
        "SwapFree": 0,
        "SwapTotal": 0,
        "arch": "amd64",
        "cpus": 12,
        "hostname": "focal",
        "kernel": "5.4.0-94-generic",
        "os": "linux",
        "rootless": true,
        "uptime": "2h 15m 44.86s (Approximately 0.08 days)"
    },
    "store": {
        "ContainerStore": {
            "number": 0
        },
        "GraphDriverName": "overlay",
        "GraphOptions": [
            "overlay.mount_program=/home/ubuntu/bin/fuse-overlayfs"
        ],
        "GraphRoot": "/home/ubuntu/.local/share/containers/storage",
        "GraphStatus": {
            "Backing Filesystem": "extfs",
            "Native Overlay Diff": "false",
            "Supports d_type": "true",
            "Using metacopy": "false"
        },
        "ImageStore": {
            "number": 0
        },
        "RunRoot": "/run/user/1000/containers"
    }
}
  1. FAIL: Rootless overlay check fails if mount_program is only set in /etc/containers/storage.conf and it is not available in $PATH.
ubuntu@focal:~$ which fuse-overlayfs
ubuntu@focal:~$ 

ubuntu@focal:~$ grep mount_program /etc/containers/storage.conf
mount_program = "/home/ubuntu/bin/fuse-overlayfs"

ubuntu@focal:~$ buildah --log-level=trace info
DEBU[0000] running [buildah-in-a-user-namespace --log-level=trace info] with environment [SHELL=/bin/bash SECURITYTAGS= PWD=/home/ubuntu LOGNAME=ubuntu XDG_SESSION_TYPE=tty MOTD_SHOWN=pam HOME=/home/ubuntu LANG=C.UTF-8 
SSH_CONNECTION=172.16.91.1 62849 172.16.91.8 22 LESSCLOSE=/usr/bin/lesspipe %s %s XDG_SESSION_CLASS=user TERM=xterm-256color LESSOPEN=| /usr/bin/lesspipe %s USER=ubuntu SHLVL=1 XDG_SESSION_ID=11 XDG_RUNTIME_DIR=/run/user/1000 SSH_CLIENT=172.16.91.1 62849 22 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin BUILDTAGS=exclude_graphdriver_devicemapper DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus SSH_TTY=/dev/pts/0 OLDPWD=/home/ubuntu/buildah _=/usr/bin/buildah TMPDIR=/var/tmp _CONTAINERS_USERNS_CONFIGURED=1 BUILDAH_ISOLATION=rootless], UID map [{ContainerID:0 HostID:1000 Size:1} {ContainerID:1 HostID:100000 Size:65536}], and GID map [{ContainerID:0 HostID:1000 Size:1} {ContainerID:1 HostID:100000 Size:65536}]
DEBU[0000] overlay storage already configured with a mount-program
DEBU[0000] [graphdriver] trying provided driver "overlay"
DEBU[0000] cached value indicated that overlay is not supported
kernel does not support overlay fs: unable to create kernel-style whiteout: operation not permitted
github.com/containers/buildah/vendor/github.com/containers/storage/drivers/overlay.checkAndRecordOverlaySupport
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/drivers/overlay/overlay.go:215
github.com/containers/buildah/vendor/github.com/containers/storage/drivers/overlay.Init
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/drivers/overlay/overlay.go:306
github.com/containers/buildah/vendor/github.com/containers/storage/drivers.GetDriver
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/drivers/driver.go:288
github.com/containers/buildah/vendor/github.com/containers/storage/drivers.New
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/drivers/driver.go:318
github.com/containers/buildah/vendor/github.com/containers/storage.(*store).getGraphDriver
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/store.go:824
github.com/containers/buildah/vendor/github.com/containers/storage.(*store).GraphDriver
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/store.go:841
github.com/containers/buildah/vendor/github.com/containers/storage.(*store).load
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/store.go:756
github.com/containers/buildah/vendor/github.com/containers/storage.GetStore
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/containers/storage/store.go:698
main.getStore
	/usr/src/packages/BUILD/src/github.com/containers/buildah/cmd/buildah/common.go:107
main.infoCmd
	/usr/src/packages/BUILD/src/github.com/containers/buildah/cmd/buildah/info.go:49
main.init.8.func1
	/usr/src/packages/BUILD/src/github.com/containers/buildah/cmd/buildah/info.go:33
github.com/containers/buildah/vendor/github.com/spf13/cobra.(*Command).execute
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:852
github.com/containers/buildah/vendor/github.com/spf13/cobra.(*Command).ExecuteC
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:960
github.com/containers/buildah/vendor/github.com/spf13/cobra.(*Command).Execute
	/usr/src/packages/BUILD/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:897
main.main
	/usr/src/packages/BUILD/src/github.com/containers/buildah/cmd/buildah/main.go:220
runtime.main
	/usr/lib/go-1.15/src/runtime/proc.go:204
runtime.goexit
	/usr/lib/go-1.15/src/runtime/asm_amd64.s:1374
DEBU[0000] overlay storage already configured with a mount-program
DEBU[0000] [graphdriver] trying provided driver "overlay"
DEBU[0000] cached value indicated that overlay is not supported
WARN[0000] failed to shutdown storage: "kernel does not support overlay fs: unable to create kernel-style whiteout: operation not permitted"
ERRO[0000] exit status 125

Describe the results you received: Overlay check fails.

Describe the results you expected: Overlay check should pass if mount_program path is correctly configured in /etc/container/storage.conf.

Output of rpm -q buildah or apt list buildah:

ubuntu@focal:~$ apt list buildah
Listing... Done
buildah/unknown,now 100:1.21.3-1 amd64 [installed]
buildah/unknown 100:1.21.3-1 arm64
buildah/unknown 100:1.21.3-1 armhf
buildah/unknown 100:1.21.3-1 s390x

Output of buildah version:

ubuntu@focal:~$ buildah version
Version:         1.21.3
Go Version:      go1.15.2
Image Spec:      1.0.1-dev
Runtime Spec:    1.0.2-dev
CNI Spec:        0.4.0
libcni Version:
image Version:   5.12.0
Git Commit:
Built:           Wed Dec 31 19:00:00 1969
OS/Arch:         linux/amd64

Output of podman version if reporting a podman build issue:

(paste your output here)

Output of cat /etc/*release:

ubuntu@focal:~$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Output of uname -a:

ubuntu@focal:~$ uname -a
Linux focal 5.4.0-94-generic containers/buildah#106-Ubuntu SMP Thu Jan 6 23:58:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of cat /etc/containers/storage.conf:

ubuntu@focal:~$ cat /etc/containers/storage.conf
# This file is is the configuration file for all tools
# that use the containers/storage library.
# See man 5 containers-storage.conf for more information
# The "container storage" table contains all of the server options.
[storage]

# Default Storage Driver, Must be set for proper operation.
driver = "overlay"

# Temporary storage location
runroot = "/run/containers/storage"

# Primary Read/Write location of container storage
graphroot = "/var/lib/containers/storage"

# Storage path for rootless users
#
# rootless_storage_path = "$HOME/.local/share/containers/storage"

[storage.options]
# Storage options to be passed to underlying storage drivers

# AdditionalImageStores is used to pass paths to additional Read/Only image stores
# Must be comma separated list.
additionalimagestores = [
]

# Remap-UIDs/GIDs is the mapping from UIDs/GIDs as they should appear inside of
# a container, to the UIDs/GIDs as they should appear outside of the container,
# and the length of the range of UIDs/GIDs.  Additional mapped sets can be
# listed and will be heeded by libraries, but there are limits to the number of
# mappings which the kernel will allow when you later attempt to run a
# container.
#
# remap-uids = 0:1668442479:65536
# remap-gids = 0:1668442479:65536

# Remap-User/Group is a user name which can be used to look up one or more UID/GID
# ranges in the /etc/subuid or /etc/subgid file.  Mappings are set up starting
# with an in-container ID of 0 and then a host-level ID taken from the lowest
# range that matches the specified name, and using the length of that range.
# Additional ranges are then assigned, using the ranges which specify the
# lowest host-level IDs first, to the lowest not-yet-mapped in-container ID,
# until all of the entries have been used for maps.
#
# remap-user = "containers"
# remap-group = "containers"

# Root-auto-userns-user is a user name which can be used to look up one or more UID/GID
# ranges in the /etc/subuid and /etc/subgid file.  These ranges will be partitioned
# to containers configured to create automatically a user namespace.  Containers
# configured to automatically create a user namespace can still overlap with containers
# having an explicit mapping set.
# This setting is ignored when running as rootless.
# root-auto-userns-user = "storage"
#
# Auto-userns-min-size is the minimum size for a user namespace created automatically.
# auto-userns-min-size=1024
#
# Auto-userns-max-size is the minimum size for a user namespace created automatically.
# auto-userns-max-size=65536

[storage.options.overlay]
# ignore_chown_errors can be set to allow a non privileged user running with
# a single UID within a user namespace to run containers. The user can pull
# and use any image even those with multiple uids.  Note multiple UIDs will be
# squashed down to the default uid in the container.  These images will have no
# separation between the users in the container. Only supported for the overlay
# and vfs drivers.
#ignore_chown_errors = "false"

# Inodes is used to set a maximum inodes of the container image.
# inodes = ""

# Path to an helper program to use for mounting the file system instead of mounting it
# directly.
mount_program = "/home/ubuntu/bin/fuse-overlayfs"

# mountopt specifies comma separated list of extra mount options
mountopt = "nodev,metacopy=on"

# Set to skip a PRIVATE bind mount on the storage home directory.
# skip_mount_home = "false"

# Size is used to set a maximum size of the container image.
# size = ""

# ForceMask specifies the permissions mask that is used for new files and
# directories.
#
# The values "shared" and "private" are accepted.
# Octal permission masks are also accepted.
#
#  "": No value specified.
#     All files/directories, get set with the permissions identified within the
#     image.
#  "private": it is equivalent to 0700.
#     All files/directories get set with 0700 permissions.  The owner has rwx
#     access to the files. No other users on the system can access the files.
#     This setting could be used with networked based homedirs.
#  "shared": it is equivalent to 0755.
#     The owner has rwx access to the files and everyone else can read, access
#     and execute them. This setting is useful for sharing containers storage
#     with other users.  For instance have a storage owned by root but shared
#     to rootless users as an additional store.
#     NOTE:  All files within the image are made readable and executable by any
#     user on the system. Even /etc/shadow within your image is now readable by
#     any user.
#
#   OCTAL: Users can experiment with other OCTAL Permissions.
#
#  Note: The force_mask Flag is an experimental feature, it could change in the
#  future.  When "force_mask" is set the original permission mask is stored in
#  the "user.containers.override_stat" xattr and the "mount_program" option must
#  be specified. Mount programs like "/usr/bin/fuse-overlayfs" present the
#  extended attribute permissions to processes within containers rather then the
#  "force_mask"  permissions.
#
# force_mask = ""

[storage.options.thinpool]
# Storage Options for thinpool

# autoextend_percent determines the amount by which pool needs to be
# grown. This is specified in terms of % of pool size. So a value of 20 means
# that when threshold is hit, pool will be grown by 20% of existing
# pool size.
# autoextend_percent = "20"

# autoextend_threshold determines the pool extension threshold in terms
# of percentage of pool size. For example, if threshold is 60, that means when
# pool is 60% full, threshold has been hit.
# autoextend_threshold = "80"

# basesize specifies the size to use when creating the base device, which
# limits the size of images and containers.
# basesize = "10G"

# blocksize specifies a custom blocksize to use for the thin pool.
# blocksize="64k"

# directlvm_device specifies a custom block storage device to use for the
# thin pool. Required if you setup devicemapper.
# directlvm_device = ""

# directlvm_device_force wipes device even if device already has a filesystem.
# directlvm_device_force = "True"

# fs specifies the filesystem type to use for the base device.
# fs="xfs"

# log_level sets the log level of devicemapper.
# 0: LogLevelSuppress 0 (Default)
# 2: LogLevelFatal
# 3: LogLevelErr
# 4: LogLevelWarn
# 5: LogLevelNotice
# 6: LogLevelInfo
# 7: LogLevelDebug
# log_level = "7"

# min_free_space specifies the min free space percent in a thin pool require for
# new device creation to succeed. Valid values are from 0% - 99%.
# Value 0% disables
# min_free_space = "10%"

# mkfsarg specifies extra mkfs arguments to be used when creating the base
# device.
# mkfsarg = ""

# metadata_size is used to set the `pvcreate --metadatasize` options when
# creating thin devices. Default is 128k
# metadata_size = ""

# Size is used to set a maximum size of the container image.
# size = ""

# use_deferred_removal marks devicemapper block device for deferred removal.
# If the thinpool is in use when the driver attempts to remove it, the driver
# tells the kernel to remove it as soon as possible. Note this does not free
# up the disk space, use deferred deletion to fully remove the thinpool.
# use_deferred_removal = "True"

# use_deferred_deletion marks thinpool device for deferred deletion.
# If the device is busy when the driver attempts to delete it, the driver
# will attempt to delete device every 30 seconds until successful.
# If the program using the driver exits, the driver will continue attempting
# to cleanup the next time the driver is used. Deferred deletion permanently
# deletes the device and all data stored in device will be lost.
# use_deferred_deletion = "True"

# xfs_nospace_max_retries specifies the maximum number of retries XFS should
# attempt to complete IO when ENOSPC (no space) error is returned by
# underlying storage device.
# xfs_nospace_max_retries = "0"

mrinaldhillon avatar Jan 17 '22 20:01 mrinaldhillon

@giuseppe PTAL

rhatdan avatar Jan 18 '22 11:01 rhatdan

I don't think we use /etc/containers/storage.conf for rootless, except for rootless_storage_path.

I am not sure whether we should do that, the storage configuration can be very different for root and rootless (e.g. many overlay options won't work with rootless).

Can you set the mount_path in the user storage.conf file?

giuseppe avatar Jan 19 '22 10:01 giuseppe

@giuseppe We would like to avoid user-specific configurations. Usecase here to configure sane global defaults to ensure consistent/reproducible behavior for all users across shared servers.

I am not sure whether we should do that, the storage configuration can be very different for root and rootless (e.g. many overlay options won't work with rootless).

AFAIK mount_program and ignore_chown_errors are relevant only to rootless?

mrinaldhillon avatar Jan 19 '22 17:01 mrinaldhillon

I'm hitting a somewhat similar looking problem if using a non-standard runtime name. See containers/buildah#3721 for details.

dgibson avatar Jan 20 '22 03:01 dgibson

@giuseppe We would like to avoid user-specific configurations. Usecase here to configure sane global defaults to ensure consistent/reproducible behavior for all users across shared servers.

is there any reason to not let containers/storage pick the correct default? Wouldn't that work if fuse-overlayfs is in $PATH?

I am not sure whether we should do that, the storage configuration can be very different for root and rootless (e.g. many overlay options won't work with rootless).

AFAIK mount_program and ignore_chown_errors are relevant only to rootless?

I think mount_program can also be useful for root

giuseppe avatar Jan 20 '22 11:01 giuseppe