edacval
September 28, 2021, 3:26am
1
I am using custom volume “sharedvol” in default storage pool to share common data between two containers.
Every time when i stopping any one of two active containers lxd logs to journald:
lvl=eror msg="Failed to stop device" devName=sharedvol err="In use" instance=first_to_stop instanceType=container project=default
How to reproduce:
lxc storage volume create default sharedvol
lxc image copy images:archlinux local: --copy-aliases
lxc init local:archlinux cont1
lxc init local:archlinux cont2
lxc config device add cont1 sharedvol disk pool=default source=sharedvol path=/drop
lxc config device add cont2 sharedvol disk pool=default source=sharedvol path=/drop
lxc start cont1 cont2
sleep 5
lxc stop cont1 cont2
journalctl -u lxd.service -n 1:
Sep 28 05:37:04 lxdsrv lxd[856]: t=2021-09-28T05:37:04+0300 lvl=eror msg="Failed to stop device" devName=sharedvol err="In use" instance=cont1 instanceType=container project=default
Do I understand correctly that this is just a misleading error message and not a real bug ?
Archlinux linux-lts=5.10.69 lxd=4.18 zfs=2.1.1
This is indeed only a misleading error message. When you call lxc stop cont1 cont2
, LXD will stop cont1
first and try to unmount the device as well. However, since the device is still in use by cont2
, it shows the error message.
It doesn’t happen with all storage drivers, but on zfs it does.
This should be an easy fix.
edacval
September 28, 2021, 9:43am
4
Thanks for confirming my conclusion
tomp
(Thomas Parrott)
September 29, 2021, 8:43am
5
We’ve reworked the fix in:
lxc:master
← tomponline:tp-storage-volume-mountref
opened 08:40AM - 29 Sep 21 UTC
Detect the `storageDrivers.ErrInUse` error in the instance `disk` device post st… op hook when unmounting a custom volume to avoid logging an error like:
```
EROR[09-29|09:11:32] Failed to stop device instanceType=container instance=c1 project=test err="In use" devName=sharedvol
```
Instead let the `disk` device ignore it, and ensure all storage drivers have mount ref counting (even if they don't actually do mount/unmounts, for consistent behaviour across storage drivers).
The storage drivers will then log a debug message:
```
DBUG[09-29|09:39:34] Skipping unmount as in use pool=default driver=dir volName=test_sharedvol refCount=1
```
This issue was reported in https://discuss.linuxcontainers.org/t/lxd-eror-message-failed-to-stop-device/12247.
A continuation of the work done by @monstermunchkin in https://github.com/lxc/lxd/pull/9299