project-stacker / stacker

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

Failed to create lock for atomix-builder if XDG_RUNTIME_DIR is not set. #281

Open smoser opened 2 years ago

smoser commented 2 years ago

Running stacker build, we hit this issue yesterday. It failed with Failed to create lock for atomix-builder.

The actual failure was coming from liblxc src/lxc/lxclock.c was calling get_rundir (link).

The failure path was:

One thing to note is we didn't get any of the 'INFO' message output... that probably would have been helpful.

One easy way to improve this, which would unfortunately add knowledge to stacker which may at some point be incorrect would be to just have stacker check those conditions early and erroring with:

XDG_RUNTIME_DIR was not set, fallback path of HOME/.cache/lxc/run did not exist.  

Also... stacker could just create that HOME/.cache/lxc/run path.

stacker  --storage-type=overlay --oci-dir=stacker/ocidir
   --roots-dir=stacker/roots 
   --stacker-dir=stacker/stacker build 
   --stacker-file=stacker.yaml
preparing image build-env...
using cached copy of /data/hdd/gmeo/smoser/atomix/tools/collect-gomods
using cached copy of /data/hdd/gmeo/smoser/atomix/atomix/go.sum
using cached copy of /data/hdd/gmeo/smoser/atomix/atomix/go.mod
loading docker://aci-docker-reg.cisco.com/c3/godev:1.0.0-beta_u40
preparing image atomix-builder...
rebuilding cached layer due to use of binds in stacker file
Failed to create lock for atomix-builder
error: allocating the container failed
error: exit status 1
smoser commented 2 years ago

Another important bit of info here is that HOME/.cache was a symlink to a non-existing dir. After creating the directory that it pointed to it worked correctly.

So in order to trigger this, you have to: a. have XDG_RUNTIME_DIR unset b. rm -Rf $HOME/.cache ; ln -s $HOME/non-existant ~/.cache

tych0 commented 2 years ago

it does feel like the right fix is to just have liblxc use the lxcpath for this locking, vs. trying to do it somewhere global.