dalec
dalec copied to clipboard
[BUG] State under subpath from base image is not persisted when using image source
Expected Behavior
When a user makes use of an image source, they should be able to run commands in the context of that base image, including being able to rely on the presence of files under arbitrary subpaths
Actual Behavior
If a user specifies a non-root subpath to extract from the base image then we mount a scratch fs over said path without accounting for what might have been at that path, meaning that commands meant to execute in the context of the base image may fail and files from the base image under a particular subpath that were meant to be persisted when the subpath contents are extracted will not be copied as part of the source.
Steps To Reproduce
Consider the following spec:
# syntax=ghcr.io/azure/dalec/frontend:latest
name: test-dalec-package
packager: Microsoft
version: 0.1
revision: 1
description: "A test package"
license: "Apache 2.0"
sources:
img:
path: "/etc"
image:
ref: "busybox:latest"
cmd:
steps:
- command: "ls -lrt /etc"
build:
steps:
- command: |
[ ! -z $(ls -A img/) ]
The contents of /etc
from busybox
should be available under the img
source directory, and the test command within the build steps should succeed. Instead, the build fails because there are no files in the img
source directory. This is due to faulty current behavior in our source-from-image implementation in which we unconditionally mount a scratch fs over any non-root subpath a user has provided in the base image.
Are you willing to submit PRs to contribute to this bug fix?
- [x] Yes, I am willing to implement it.