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

bud: COPY . . too aggressive with caching #1780

Closed
adambkaplan opened this issue Aug 9, 2019 · 4 comments
Closed

bud: COPY . . too aggressive with caching #1780

adambkaplan opened this issue Aug 9, 2019 · 4 comments

Comments

@adambkaplan
Copy link

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

/kind bug

Description

During podman build, if the Dockerfile contains the COPY . . instruction, podman uses cache even if the underlying files change in a meaningful way

Steps to reproduce the issue:

  1. Start in a git repository with a Dockerfile that contains a COPY . . instruction. Example: https://github.com/openshift/cluster-image-registry-operator

  2. run $ podman build -t myimage:mytag .

  3. Change a file within Podman's build context (ex: add text to README.md)

  4. Re-run $ podman build -t myimage:mytag .

Describe the results you received:

Podman uses a cached layer:

STEP 3: COPY . .
--> Using cache 9e671982f175dea422a5dfc7222e1b5ff282f98acf4515c86e801d3a1734e396

Describe the results you expected:

Podman should have done a fresh copy to pull in new content.

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

Output of podman version:

Version:            1.4.4
RemoteAPI Version:  1
Go Version:         go1.12.7
OS/Arch:            linux/amd64

Output of podman info --debug:

debug:
  compiler: gc
  git commit: ""
  go version: go1.12.7
  podman version: 1.4.4
host:
  BuildahVersion: 1.9.0
  Conmon:
    package: podman-1.4.4-4.fc30.x86_64
    path: /usr/libexec/podman/conmon
    version: 'conmon version 1.0.0-dev, commit: 164df8af4e62dc759c312eab4b97ea9fb6b5f1fc'
  Distribution:
    distribution: fedora
    version: "30"
  MemFree: 4410179584
  MemTotal: 16687108096
  OCIRuntime:
    package: runc-1.0.0-93.dev.gitb9b6cc6.fc30.x86_64
    path: /usr/bin/runc
    version: |-
      runc version 1.0.0-rc8+dev
      commit: e3b4c1108f7d1bf0d09ab612ea09927d9b59b4e3
      spec: 1.0.1-dev
  SwapFree: 8413769728
  SwapTotal: 8413769728
  arch: amd64
  cpus: 8
  hostname: localhost.localdomain
  kernel: 5.1.17-300.fc30.x86_64
  os: linux
  rootless: true
  uptime: 26m 48.98s
registries:
  blocked: null
  insecure:
  - 172.30.0.0/16
  search:
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.access.redhat.com
  - registry.centos.org
store:
  ConfigFile: /home/adkaplan/.config/containers/storage.conf
  ContainerStore:
    number: 91
  GraphDriverName: overlay
  GraphOptions:
  - overlay.mount_program=/usr/bin/fuse-overlayfs
  GraphRoot: /home/adkaplan/.local/share/containers/storage
  GraphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  ImageStore:
    number: 379
  RunRoot: /run/user/1000
  VolumePath: /home/adkaplan/.local/share/containers/storage/volumes

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

Fedora 30 desktop

Output of cat /etc/*release:

NAME=Fedora
VERSION="30 (Workstation Edition)"
ID=fedora
VERSION_ID=30
VERSION_CODENAME=""
PLATFORM_ID="platform:f30"
PRETTY_NAME="Fedora 30 (Workstation Edition)"
ANSI_COLOR="0;34"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:30"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f30/system-administrators-guide/"
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=30
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=30
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
Fedora release 30 (Thirty)
Fedora release 30 (Thirty)

Output of uname -a:

Linux localhost.localdomain 5.1.17-300.fc30.x86_64 #1 SMP Wed Jul 10 15:20:27 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Output of 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,metacopy=on"

# 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"
@nalind nalind self-assigned this Aug 9, 2019
@TomSweeneyRedHat
Copy link
Member

@QiWang19 I think you've been working on a related issue?

@E100Beta
Copy link

E100Beta commented Sep 3, 2019

Came here from containers/podman#3920 - this issue seems to be isolated to multi-stage builds for me, single-stage builds seem to cache correctly. Podman 1.5.1.

@TomSweeneyRedHat
Copy link
Member

I think this is now working in Buildah 1.10.1, or perhaps my testing was off? @adambkaplan could you verify the following test? I'm seeing the cache being reused only when the file has not changed.

# cat ~/Dockerfile
FROM busybox
COPY . . 

# buildah bud --rm --layers -t tom -f ~/Dockerfile .
STEP 1: FROM busybox
Getting image source signatures
Copying blob ee153a04d683 done
Copying config db8ee88ad7 done
Writing manifest to image destination
Storing signatures
STEP 2: COPY . . 
STEP 3: COMMIT tom
522b6e604a1076639f3e5e423de8d9bea0aa2064f3abbb55f8e143379b3503e6

# cat tommer.txt
My oh my what a day

# vi tommer.txt

# cat tommer.txt
My oh my what a day
My oh my what a day

# buildah bud --rm --layers -t tom -f ~/Dockerfile .
STEP 1: FROM busybox
STEP 2: COPY . . 
STEP 3: COMMIT tom
899ed2e4bc37c507380220017bfde653932d957048c68ed2bb77d1e95ce4800f

# Rerun build without changing tommer.txt:
# buildah bud --rm --layers -t tom -f ~/Dockerfile .
STEP 1: FROM busybox
STEP 2: COPY . . 
--> Using cache 899ed2e4bc37c507380220017bfde653932d957048c68ed2bb77d1e95ce4800f
STEP 3: COMMIT tom
899ed2e4bc37c507380220017bfde653932d957048c68ed2bb77d1e95ce4800f

# buildah version
Version:         1.10.1
Go Version:      go1.12.7
Image Spec:      1.0.1
Runtime Spec:    1.0.1-dev
CNI Spec:        0.4.0
libcni Version:  
Git Commit:      
Built:           Wed Dec 31 19:00:00 1969
OS/Arch:         linux/amd64

@TomSweeneyRedHat
Copy link
Member

I've not been able to duplicate this using Buildah v1.11.0 which should be in the next release of Podman. I'm not sure if that will be Podman 1.5.1 or Podman 1.6.0, but it will be contained that next version. I'm going to close this now as #1792 appears to have fixed the issue. If you find otherwise, please feel free to reopen this or create a new issue as appropriate.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants