Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running nonexistent command with readonly root FS does not fail #254

Open
aaronlehmann opened this issue Jul 28, 2021 · 3 comments
Open

Comments

@aaronlehmann
Copy link
Contributor

➜  hlb git:(6f04a1d) ✗ cat bug.hlb
fs default() {
        image "alpine"
        run "doesnotexist" with option {
                readonlyRootfs
        }
}
➜  hlb git:(6f04a1d) ✗ go run ./cmd/hlb run bug.hlb
[+] Building 0.7s (2/2) FINISHED
 => resolve image config for docker.io/library/alpine:latest                                                                    0.4s
 => CACHED docker-image://docker.io/library/alpine:latest                                                                       0.0s
 => => resolve docker.io/library/alpine:latest                                                                                  0.2s
➜  hlb git:(6f04a1d) ✗ echo $?
0

Does the run get optimized out of the build graph because the readonly root FS means it can't have side effects? I'm not sure this is expected behavior, since it could have side effects outside the context of the filesystem.

cc @hinshun @coryb

@coryb
Copy link
Contributor

coryb commented Jul 28, 2021

yes, it is expected, it is optimized out since it can't possibly have side effects. You would need a writable mount for it not to be pruned.

@aaronlehmann
Copy link
Contributor Author

What if it was a curl command making a call to an external API?

@coryb
Copy link
Contributor

coryb commented Jul 28, 2021

Yeah, not saying it is ideal, just the way buildkit works. I am not sure there is any practical usage of readonlyRootfs except possibly with an aliased mount. Buildkit is designed for artifact generation, not really for arbitrary execution. Perhaps we could get HLB to print a warning when readonlyRootfs is used without an aliased mount? We could probably also remove the option. The curl usage will work if we just don't explicitly tell buildkit that there are no outputs with readonlyRootfs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants