weixin_39615956
weixin_39615956
2021-01-09 07:58

buildah run registry fails on first attempt.

Description

When running a container image registry to create a password file, the first attempt fails, but the second attempt succeeds. The error is /var/lib/registry can't be gotten to on the container.

Steps to reproduce the issue: 1. registry=$(buildah from registry:2) 2. buildah --debug run $registry -- htpasswd -Bbn testuser testpassword > /root/auth/htpasswd 3. buildah --debug run $registry -- htpasswd -Bbn testuser testpassword > /root/auth/htpasswd

Describe the results you received:


# registry=$(buildah from registry:2)
Getting image source signatures
Copying blob sha256:d6a5679aa3cfc52503fac8e2345790783537564df5af43355ec662d7703aacbf
 2.28 MiB / 2.28 MiB [======================================================] 0s
Copying blob sha256:ad0eac849f8f2014e20df11d611e4453c94a365a71eb3a90f02d8500391e1787
 1.94 MiB / 1.94 MiB [======================================================] 0s
Copying blob sha256:2261ba058a15e3f21a467b1b02ea206d40cf0632d6b1aeee2ad200b662ed4aff
 5.98 MiB / 5.98 MiB [======================================================] 0s
Copying blob sha256:f296fda86f10cfcb81d60d5bcb47a7784a8ec4876d6eac7fabd51f2a7e8694aa
 369 B / 369 B [============================================================] 0s
Copying blob sha256:bcd4a541795bb9981999ce8f6e2e1c92e55b0041256153d2458ff35fb9381063
 212 B / 212 B [============================================================] 0s
Copying config sha256:2e2f252f3c88679f1207d87d57c07af6819a1a17e22573bcef32804122d2f305
 3.09 KiB / 3.09 KiB [======================================================] 0s
Writing manifest to image destination
Storing signatures

# buildah --debug run $registry -- htpasswd -Bbn testuser testpassword > /root/auth/htpasswd
DEBU[0000] [graphdriver] trying provided driver "overlay" 
DEBU[0000] overlay: override_kernelcheck=true           
DEBU[0000] overlay test mount with multiple lowers succeeded 
DEBU[0000] backingFs=xfs, projectQuotaSupported=false, useNativeDiff=true 
DEBU[0000] using "/tmp/buildah198005705" to hold bundle data 
DEBU[0000] Resources: &buildah.CommonBuildOptions{AddHost:[]string{}, CgroupParent:"", CPUPeriod:0x0, CPUQuota:0, CPUShares:0x0, CPUSetCPUs:"", CPUSetMems:"", Memory:0, MemorySwap:0, LabelOpts:[]string(nil), SeccompProfilePath:"/usr/share/containers/seccomp.json", ApparmorProfile:"", ShmSize:"65536k", Ulimit:[]string{"nofile=1048576:1048576", "nproc=1048576:1048576"}, Volumes:[]string{}} 
DEBU[0000] stdio is not a terminal, defaulting to not using a terminal 
DEBU[0000] ensuring working directory "/var/lib/containers/storage/overlay/3e1b36fa7378c7748727e824e2c2007fcb5fee40186c1fc61efd6c0898cc32ee/merged" exists 
DEBU[0000] CopyFileWithTar(/etc/hosts, /tmp/buildah198005705/hosts) 
DEBU[0000] CopyFileWithTar(/etc/resolv.conf, /tmp/buildah198005705/resolv.conf) 
DEBU[0000] /etc/system-fips does not exist on host, not mounting FIPS mode secret 
DEBU[0000] error running [htpasswd -Bbn testuser testpassword] in container "registry-working-container": error resolving mountpoints for container: failed to stat "/var/lib/containers/storage/overlay/3e1b36fa7378c7748727e824e2c2007fcb5fee40186c1fc61efd6c0898cc32ee/merged/var/lib/registry" for volume "/var/lib/registry": stat /var/lib/containers/storage/overlay/3e1b36fa7378c7748727e824e2c2007fcb5fee40186c1fc61efd6c0898cc32ee/merged/var/lib/registry: no such file or directory 
ERRO[0000] error resolving mountpoints for container: failed to stat "/var/lib/containers/storage/overlay/3e1b36fa7378c7748727e824e2c2007fcb5fee40186c1fc61efd6c0898cc32ee/merged/var/lib/registry" for volume "/var/lib/registry": stat /var/lib/containers/storage/overlay/3e1b36fa7378c7748727e824e2c2007fcb5fee40186c1fc61efd6c0898cc32ee/merged/var/lib/registry: no such file or directory 

# buildah --debug run $registry -- htpasswd -Bbn testuser testpassword > /root/auth/htpasswd
DEBU[0000] [graphdriver] trying provided driver "overlay" 
DEBU[0000] overlay: override_kernelcheck=true           
DEBU[0000] overlay test mount with multiple lowers succeeded 
DEBU[0000] backingFs=xfs, projectQuotaSupported=false, useNativeDiff=true 
DEBU[0000] using "/tmp/buildah923526556" to hold bundle data 
DEBU[0000] Resources: &buildah.CommonBuildOptions{AddHost:[]string{}, CgroupParent:"", CPUPeriod:0x0, CPUQuota:0, CPUShares:0x0, CPUSetCPUs:"", CPUSetMems:"", Memory:0, MemorySwap:0, LabelOpts:[]string(nil), SeccompProfilePath:"/usr/share/containers/seccomp.json", ApparmorProfile:"", ShmSize:"65536k", Ulimit:[]string{"nofile=1048576:1048576", "nproc=1048576:1048576"}, Volumes:[]string{}} 
DEBU[0000] stdio is not a terminal, defaulting to not using a terminal 
DEBU[0000] ensuring working directory "/var/lib/containers/storage/overlay/3e1b36fa7378c7748727e824e2c2007fcb5fee40186c1fc61efd6c0898cc32ee/merged" exists 
DEBU[0000] CopyFileWithTar(/etc/hosts, /tmp/buildah923526556/hosts) 
DEBU[0000] CopyFileWithTar(/etc/resolv.conf, /tmp/buildah923526556/resolv.conf) 
DEBU[0000] /etc/system-fips does not exist on host, not mounting FIPS mode secret 
DEBU[0000] bind mounted "/var/lib/containers/storage/overlay/3e1b36fa7378c7748727e824e2c2007fcb5fee40186c1fc61efd6c0898cc32ee/merged" to "/tmp/buildah923526556/mnt/rootfs" 
DEBU[0000] bind mounted "/var/lib/containers/storage/overlay-containers/324ffe47b62b08afaeb953846c79a67158062b29e0eaa9a0fde93c21869ca176/userdata/buildah-volumes/0373a45b84731daa05fc77ff8ea852f49668fd5246f759bfdd0a3c89ef647bd7" to "/tmp/buildah923526556/mnt/buildah-bind-target-0" 
DEBU[0000] bind mounted "/var/lib/containers/storage/overlay-containers/324ffe47b62b08afaeb953846c79a67158062b29e0eaa9a0fde93c21869ca176/userdata/run/secrets" to "/tmp/buildah923526556/mnt/buildah-bind-target-1" 
DEBU[0000] config = {"ociVersion":"1.0.0", {Edited out the rest for brevity.
DEBU[0000] Running ["runc" "create" "--bundle" "/tmp/buildah923526556" "--pid-file" "/tmp/buildah923526556/pid" "buildah-buildah923526556"] 
DEBU[0000] Running ["runc" "start" "buildah-buildah923526556"] 

Describe the results you expected:

The /root/auth/htpasswd file to have been created with valid data

Output of rpm -q buildah or apt list buildah:


# rpm -q buildah
buildah-1.4-3.git608fa84.fc29.x86_64

Output of buildah version:


# buildah version
strconv.ParseInt: parsing "": invalid syntax

Output of cat /etc/*release:


# cat /etc/*release
Fedora release 29 (Twenty Nine)
NAME=Fedora
VERSION="29 (Server Edition)"
ID=fedora
VERSION_ID=29
PLATFORM_ID="platform:f29"
PRETTY_NAME="Fedora 29 (Server Edition)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:29"
HOME_URL="https://fedoraproject.org/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=29
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=29
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Server Edition"
VARIANT_ID=server
Fedora release 29 (Twenty Nine)
Fedora release 29 (Twenty Nine)

Output of uname -a:


# uname -a
Linux localhost.localdomain 4.18.13-300.fc29.x86_64 #1 SMP Wed Oct 10 17:22:50 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

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


# 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
driver = "overlay"

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

# Primary Read/Write location of container storage
graphroot = "/var/lib/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 = [
]

# Size is used to set a maximum size of the container image.  Only supported by
# certain container storage drivers.
size = ""

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

# OverrideKernelCheck tells the driver to ignore kernel checks based on kernel version
override_kernel_check = "true"

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

# Remap-UIDs/GIDs is the mapping from UIDs/GIDs as they should appear inside of
# a container, to 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 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 the 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 container-level ID,
# until all of the entries have been used for maps.
#
# remap-user = "storage"
# remap-group = "storage"

[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 = ""

# 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"

# If specified, use OSTree to deduplicate files with the overlay backend
ostree_repo = ""

# Set to skip a PRIVATE bind mount on the storage home directory.  Only supported by
# certain container storage drivers
skip_mount_home = "false"

该提问来源于开源项目:containers/buildah

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39615956 weixin_39615956 4月前

    I think the issue is the registry image has a volume defined, /var/lib/registry.

    
              "Image": "sha256:bc0d86131a2db92f18b8413a38da41718748b152024be47a8bc9413fa1d50a95",
                "Volumes": {
                    "/var/lib/registry": {}
                },
    

    That's not getting created as it should be. So the stat is failing for the srcPath at: https://github.com/containers/buildah/blob/master/run.go#L513 due to it not being created. Then the next time through the volumePath now exists so it never gets into that stat check code to fail again and then moves on to the bind mounts. Not sure how to correct it yet, need to dig further.

    点赞 评论 复制链接分享
  • weixin_39980082 weixin_39980082 4月前

    I'm reproducing something very similar with podman build. I get the same error, even if I actually provide a volume. After the failures, I also see some leftover mounts that don't get cleaned up. I ran this on a FAH 28 VM with the latest updates applied:

    
    [root ~]# mkdir context
    [root ~]# cd context
    [root context]# vim Dockerfile
    bash: vim: command not found
    [root context]# vi Dockerfile
    [root context]# cat Dockerfile
    FROM registry.centos.org/centos/systemd
    RUN sleep 1s
    [root context]# podman build -t test .
    STEP 1: FROM registry.centos.org/centos/systemd
    Getting image source signatures
    Copying blob sha256:9fd0835072117c2226c8ae1334aaf880e02edbba573329c3e3bcb7f6136a0dac
     71.23 MB / 71.23 MB [=====================================================] 24s
    Copying blob sha256:16f9894e71734b66cd5071fbd0a46a38f23bc3f4316c81ab2d770e4cb465dc21
     1.22 KB / 1.22 KB [========================================================] 0s
    Copying config sha256:726479086e9db10b9f58096625df029d27dc936acf11b9aeef23a324e171c079
     3.66 KB / 3.66 KB [========================================================] 0s
    Writing manifest to image destination
    Storing signatures
    STEP 2: RUN sleep 1s
    error building at step {Env:[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin container=docker] Command:run Args:[sleep 1s] Flags:[] Attrs:map[] Message:RUN sleep 1s Original:RUN sleep 1s}: error resolving mountpoints for container: failed to stat "/var/lib/containers/storage/overlay/4c7e146b4e80e743b0514c80a56ec0c7fcb28031f7309bec5d6b99c5e1d69b52/merged/sys/fs/cgroup" for volume "/sys/fs/cgroup": stat /var/lib/containers/storage/overlay/4c7e146b4e80e743b0514c80a56ec0c7fcb28031f7309bec5d6b99c5e1d69b52/merged/sys/fs/cgroup: no such file or directory
    [root context]# podman build -t test -v /sys/fs/cgroup:/sys/fs/cgroup .
    STEP 1: FROM registry.centos.org/centos/systemd
    STEP 2: RUN sleep 1s
    error building at step {Env:[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin container=docker] Command:run Args:[sleep 1s] Flags:[] Attrs:map[] Message:RUN sleep 1s Original:RUN sleep 1s}: error resolving mountpoints for container: failed to stat "/var/lib/containers/storage/overlay/9cfb6abb87fdf692a57b2e9d57a11b59fc5b046bb713be29e7a3db894f20dad5/merged/sys/fs/cgroup" for volume "/sys/fs/cgroup": stat /var/lib/containers/storage/overlay/9cfb6abb87fdf692a57b2e9d57a11b59fc5b046bb713be29e7a3db894f20dad5/merged/sys/fs/cgroup: no such file or directory
    [root context]# findmnt
    TARGET                                  SOURCE                    FSTYPE    OPTIONS
    ...cut...
    │ ├─/sys/fs/cgroup                      tmpfs                     tmpfs     ro,nosuid,nodev,noexec,seclab
    ...cut...
    │ ├─/var/lib/containers/storage/overlay /dev/mapper/atomicos-root[/ostree/deploy/fedora-atomic/var/lib/containers/storage/overlay]
    │ │                                                               xfs       rw,relatime,seclabel,attr2,in
    │ │ ├─/var/lib/containers/storage/overlay/4c7e146b4e80e743b0514c80a56ec0c7fcb28031f7309bec5d6b99c5e1d69b52/merged
    │ │ │                                   overlay                   overlay   rw,nodev,relatime,context="sy
    │ │ └─/var/lib/containers/storage/overlay/9cfb6abb87fdf692a57b2e9d57a11b59fc5b046bb713be29e7a3db894f20dad5/merged
    │ │                                     overlay                   overlay   rw,nodev,relatime,context="sy
    │ ├─/var/lib/docker/containers          /dev/mapper/atomicos-root[/ostree/deploy/fedora-atomic/var/lib/docker/containers]
    │ │                                                               xfs       rw,relatime,seclabel,attr2,in
    │ └─/var/lib/docker/overlay2            /dev/mapper/atomicos-root[/ostree/deploy/fedora-atomic/var/lib/docker/overlay2]
    ...cut...
    
    点赞 评论 复制链接分享
  • weixin_39615956 weixin_39615956 4月前

    Closed via #1126 hopefully this fixes your issue too.

    点赞 评论 复制链接分享
  • weixin_39980082 weixin_39980082 4月前

    I'm sure it does thanks!

    点赞 评论 复制链接分享

相关推荐