skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

[ko builder] Image digest is not updated when kodata files are changed

Open strowk opened this issue 1 year ago • 0 comments

If configured inputDigest and ko builder, digest is not calculated correctly.

Expected behavior

When files are present in cmd/kodata, changing them should result in a new tag.

Actual behavior

Tag is not changing.

Information

  • Skaffold version: v2.9.0
  • Operating system: Ubuntu 20.04
  • Installed via: https://skaffold.dev/docs/install/
  • Contents of skaffold.yaml:
apiVersion: skaffold/v4beta7
kind: Config
metadata:
  name: skaffold-kodata-bug
build:
  tagPolicy:
    inputDigest: {}
  artifacts:
    - image: skaffold-kodata-bug
      ko:
        fromImage: gcr.io/distroless/static-debian12:nonroot
        main: ./cmd

Steps to reproduce the behavior

  1. mkdir skaffold-bug
  2. cd skaffold-bug
  3. mkdir cmd
cat << EOF > cmd/main.go
package main

func main() {
}
EOF
  1. mkdir cmd/kodata
cat << EOF > cmd/kodata/test.txt
test 1
EOF
cat << EOF > skaffold.yaml
apiVersion: skaffold/v4beta7
kind: Config
metadata:
  name: skaffold-kodata-bug
build:
  tagPolicy:
    inputDigest: {}
  artifacts:
    - image: skaffold-kodata-bug
      ko:
        fromImage: gcr.io/distroless/static-debian12:nonroot
        main: ./cmd
EOF
  1. skaffold build --dry-run , remember which tag is generated
cat << EOF > cmd/kodata/test.txt
test 2
EOF
  1. skaffold build --dry-run Expected different tag, actual is same.

I understand this can be bypassed by specifying dependencies, but that IMO would somewhat defeat the purpose of having inputDigest in the first place (which is supposed to be only changed when actually used sources are changed, but for this to work we would have to manually specify all reachable go packages).

strowk avatar Jul 02 '24 14:07 strowk