project-stacker/stacker

Bug: stacker does not notice import file changed

Opened this issue · 2 comments

stacker version

v1.0.0-rc5-396ff9d liblxc cb8e38aca27a23964941f0f011a8919aab8bebab

Describe the bug

When using import with a destination, stacker does not realize that a imported file has changed and re-build the content.

demo:
  from:
    type: docker
    url: ${{IMAGE:docker://busybox:latest}}
  import:
    - path: import1.txt
      dest: /imports/
  run: |
    #!/bin/sh -e
    read line < /imports/import1.txt
    echo "read $line"

Given the above stacker.yaml, run stacker build once, change the content of 'import1.txt' and then run it again. Expectation is that the build would be redone.

To reproduce

I am attaching a script to automate the testing.
stacker-test.sh.txt

Expected behavior

Build should occur a second time, after import1.txt content is changed and log should contain output showing that it built.

Screenshots

Example output

$ PATH=$PWD:$PATH ../stacker-test.sh
execute: stacker --version
stacker version stacker v1.0.0-rc5-396ff9d liblxc cb8e38aca27a23964941f0f011a8919aab8bebab
using cached busybox:latest in oci:stacker-test-imgcache:busybox:latest
# clean up any previous state.
execute: rm -Rf stacker-test.d stacker-test.log.1 stacker-test.log.2 import1.txt

# Write FIRST-BUILD to import1.txt and build

Updated import1.txt with 'FIRST-BUILD'
execute: stacker --work-dir=stacker-test.d build --stacker-file=stacker-test.yaml --substitute=IMAGE=oci:stacker-test-imgcache:busybox:latest
preparing image demo...
copying /tmp/dd/import1.txt
loading oci:stacker-test-imgcache:busybox:latest
--------- read FIRST-BUILD ---------
filesystem demo built successfully

execute: grep -q FIRST-BUILD stacker-test.log.1
found FIRST-BUILD in stacker-test.log.1

# Now update import1.txt with SECOND-BUILD and re-build

Updated import1.txt with 'SECOND-BUILD'
execute: stacker --work-dir=stacker-test.d build --stacker-file=stacker-test.yaml --substitute=IMAGE=oci:stacker-test-imgcache:busybox:latest
preparing image demo...
copying /tmp/dd/import1.txt
loading oci:stacker-test-imgcache:busybox:latest
found cached layer demo
execute: grep -q SECOND-BUILD stacker-test.log.2
FAIL: no occurance of "SECOND-BUILD" in log.2

Additional context

No response

HTTP HEAD request returns

< Content-Length: 34329287
< Last-Modified: Wed, 25 Oct 2023 02:50:40 GMT

and if available
< Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

HTTP HEAD request returns

< Content-Length: 34329287 < Last-Modified: Wed, 25 Oct 2023 02:50:40 GMT

and if available < Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

To be clear, this is a local file.
I suspect it is also a problem with remote imports, but local should definitely have all the information needed.

wrt remote requests ETag might also be useful.