containers / buildah

A tool that facilitates building OCI images.
https://buildah.io
Apache License 2.0
7.37k stars 781 forks source link

RUN heredoc after ARG doesn't invalidate layer #5656

Open PkmX opened 2 months ago

PkmX commented 2 months ago

Description

This seems to be related to #5225, which has been fixed. However, a slight change with an ARG before of the heredoc still does not invalidate the cache.

Steps to reproduce the issue:

$ echo -e "FROM alpine:latest\nARG foo=bar\nRUN <<EOF\necho $(date '+%s.%N')\nEOF" | buildah build --layers -
STEP 1/3: FROM alpine:latest
STEP 2/3: ARG foo=bar
--> Using cache 6e4725bb02033874e465c3f1be1e93cb71baa3b28ae2f7a4ce4454e33fceea6d
--> 6e4725bb0203
STEP 3/3: RUN <<EOF (echo 1722282857.543348323)
1722282857.543348323
COMMIT
--> e869bffc8379
e869bffc83792e1b57f098ed4b0e9e88100b15e04e3e49dd9d9d33016a8841ea

$ echo -e "FROM alpine:latest\nARG foo=bar\nRUN <<EOF\necho $(date '+%s.%N')\nEOF" | buildah build --layers -
STEP 1/3: FROM alpine:latest
STEP 2/3: ARG foo=bar
--> Using cache 6e4725bb02033874e465c3f1be1e93cb71baa3b28ae2f7a4ce4454e33fceea6d
--> 6e4725bb0203
STEP 3/3: RUN <<EOF (echo 1722282865.468415429)
--> Using cache e869bffc83792e1b57f098ed4b0e9e88100b15e04e3e49dd9d9d33016a8841ea
--> e869bffc8379
e869bffc83792e1b57f098ed4b0e9e88100b15e04e3e49dd9d9d33016a8841ea

Describe the results you received:

The second run reused the cache even though the heredoc content is different.

Describe the results you expected:

The second run should rebuild the layer.

Output of buildah version:

Version:         1.36.0
Go Version:      go1.22.4
Image Spec:      1.1.0
Runtime Spec:    1.2.0
CNI Spec:        1.0.0
libcni Version:  v1.1.2
image Version:   5.31.0
Git Commit:      6ceba8838d331eb26378cb37d9fc8ba98939aa92
Built:           Fri Jun  7 02:48:31 2024
OS/Arch:         linux/amd64
BuildPlatform:   linux/amd64
github-actions[bot] commented 1 month ago

A friendly reminder that this issue had no activity for 30 days.

apollo13 commented 1 month ago

Confirmed, @flouthoc mind looking at this one?

flouthoc commented 1 month ago

I'll take a look at this, thanks for reporting.

github-actions[bot] commented 3 weeks ago

A friendly reminder that this issue had no activity for 30 days.

cgwalters commented 2 days ago

Oh man I got burned by this one just now...