project-stacker / stacker

Build OCI images natively from a declarative format
https://stackerbuild.io
Apache License 2.0
208 stars 34 forks source link

fix: check bind source file/dir exists #624

Closed raharper closed 5 months ago

raharper commented 5 months ago

Stacker does not check if a bind mount source exists and if the source is a directory then the container crashes with a stack trace that does not indicate that the missing source dir is the issue.

Check if the source exists and return an error indicating the source is missing instead of the container stack trace.

What type of PR is this?

bug

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

$ mkdir test-binds && cd test-binds
$ cat > stacker.yaml <<EOF
hello-binds:
  from:
    type: docker
    url: docker://zothub.io/tools/busybox:stable
  binds:
    - mydir -> /mydir
  run: |
    mkdir -p /hello-stacker-app
    echo 'echo "Hello Stacker!"' > /hello-stacker-app/hello.sh
EOF
$ stacker build -f stacker.yaml

Testing done on this change:

Above test returns an error indicating that the source directory in binds is missing.

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.