project-stacker / stacker

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

Feat: check for common situations that cause inscrutable LXC errors and fail early with better warnings #631

Open mikemccracken opened 2 months ago

mikemccracken commented 2 months ago

Is your feature request related to a problem? Please describe.

In some cases the system environment is in an unexpected state, and the build container that stacker tries to start will fail to start, and we get an error message straight from LXC that someone unfamiliar with stacker's use of LXC or unfamiliar with LXC, will not find helpful.

As an example, one such case was where the environment variable XDG_RUNTIME_DIR was un-set, by a stacker wrapper trying to create a clean build environment, so lxc was using the fallback default of $HOME/.cache, which had been replaced with a symlink to /data/hdd/.cache, probably in an attempt to avoid filling whatever is mounted at $HOME, but the symlink was not owned by the user, so creating the lock file there failed, with an error like this:

loading docker://<<image name was here>>
Failed to create lock for build-sanity-d5702d7c-6074-42d1-9014-32774fb011b6
error: allocating the container failed

Describe the solution you'd like

Ideally we could have an environment-check before each build (maybe this should also do the stacker check checks), to make sure that the LXCDIR and other required things are accessible with appropriate perms, etc.

The error message should give enough detail to understand the issue and suggest solutions if possible...

Describe alternatives you've considered

No response

Additional context

No response