Skaffold: Cache hash does not change when using buildArgs

Created on 23 Sep 2019  路  5Comments  路  Source: GoogleContainerTools/skaffold

Expected behavior

When I run skaffold dev, I expect to get unique cache hashes, when my buildArgs change.

Actual behavior

The build is using the same cache key, regardless of the buildArgs

Information

  • Skaffold version: v0.38.0
  • Operating system: Ubuntu 19.04
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1beta14
kind: Config
profiles:
- name: reproduce
  build:
    local:
      useBuildkit: true
    artifacts:
    - image: reproduce
      docker:
        buildArgs:
          SOME_ARGUMENT: "{{.SOME_ARGUMENT}}"

Steps to reproduce the behavior

  1. Create a dockerfile to demonstrate that the cache is not unique per buildArg:
FROM alpine
ARG SOME_ARGUMENT
RUN echo ${SOME_ARGUMENT}
  1. Run SOME_ARGUMENT=without-cache skaffold dev --profile=reproduce
Listing files to watch...
 - reproduce
List generated in 932.731碌s
Generating tags...
 - reproduce -> reproduce:3178031-dirty
Tags generated in 2.94554ms
Checking cache...
 - reproduce: Not found. Building
Cache check complete in 389.237碌s
Starting build...
Building [reproduce]...
[+] Building 0.4s (6/6) FINISHED
 => [internal] load build definition from Dockerfile
 => => transferring dockerfile: 99B
 => [internal] load .dockerignore
 => => transferring context: 2B
 => [internal] load metadata for docker.io/library/alpine:latest
 => CACHED [1/2] FROM docker.io/library/alpine
 => [2/2] RUN echo without-cache
 => exporting to image
 => => exporting layers
 => => writing image sha256:7544cf3257de0eebbe5bcaf8136619fe76a4e21d9d4c7424740ccd94b583f375
 => => naming to reproduce:3178031-dirty
The push refers to repository [reproduce]
7a45fe20619c: Preparing
03901b4a2ea8: Preparing
03901b4a2ea8: Layer already exists
7a45fe20619c: Pushed
3178031-dirty: digest: sha256:b1307ed2a65d50c875d503a2d236fdfedc86df5a937712e9b8b9c5e77b5684e6 size: 734
Build complete in 567.474661ms
Starting test...
Test complete in 4.307碌s
Tags used in deployment:
 - reproduce -> reproduce:3178031-dirty@sha256:b1307ed2a65d50c875d503a2d236fdfedc86df5a937712e9b8b9c5e77b5684e6
Starting deploy...
  1. Run SOME_ARGUMENT=with-cache skaffold dev --profile=reproduce
Listing files to watch...
 - reproduce
List generated in 2.337227ms
Generating tags...
 - reproduce -> reproduce:3178031-dirty
Tags generated in 6.120024ms
Checking cache...
 - reproduce: Found
Cache check complete in 52.519435ms
Tags used in deployment:
 - reproduce -> reproduce:3178031-dirty@sha256:b1307ed2a65d50c875d503a2d236fdfedc86df5a937712e9b8b9c5e77b5684e6
Starting deploy...
arecache kinbug prioritp1

All 5 comments

@Multiply thanks for filing this bug, I have a PR open to fix the issue.

That was incredibly fast. Thanks!

Thanks @Multiply

Hey @Multiply I just merged the fix. It should be in the next release; here's a link to download the bleeding edge binary which should incorporate the fix now.

@priyawadhwa Thanks! I'll test it first thing in the morning.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GeertJohan picture GeertJohan  路  3Comments

r2d4 picture r2d4  路  3Comments

Morriz picture Morriz  路  3Comments

strikeout picture strikeout  路  4Comments

nathkn picture nathkn  路  3Comments