Analysis from jrtorsella

Hi Hector, as far as I can tell this looks like it is caused by a
compatibility issue/bug in rust uutils cp. I was able to reproduce this,
and when I get into the vm via the console (since lxd-agent is down) and
attempt to restart lxd-agent.service, it shows the following:

Job for lxd-agent.service failed because the control process exited with error 
code.
See "systemctl status lxd-agent.service" and "journalctl -xeu 
lxd-agent.service" for details.
In journalctl -xeu lxd-agent.service:
Aug 29 11:28:12 stonking-vm lxd-agent-setup[1772]: cp: failed to get current 
directory No such file or directory (os error 2)
Later on in journalctl it indicates the failure was in ExecStartPre, which is 
defined in /usr/lib/systemd/system/lxd-agent.service as 
/usr/lib/systemd/lxd-agent-setup

The command that fails is 'cp -Ra --no-preserve=ownership
/run/lxd_agent/.mnt/* /run/lxd_agent'. It appears that despite both
target and source locations existing and being absolute paths,
uutils/rust cp is issuing an error in case the current working directory
is unmounted. I've put together a reproducer script:

#! /usr/bin/env sh
set -e

cwd="${PWD}"
tempdir=$(mktemp -d)
cd "${tempdir}"
dd if=/dev/zero of="${tempdir}/test-disk.img" bs=1M count=10
mkfs.ext4 "${tempdir}/test-disk.img"
mkdir "${tempdir}/mountdir"
mount -o loop "${tempdir}/test-disk.img" "${tempdir}/mountdir"
mkdir -p "${tempdir}/mountdir/copy_dir/inner_dir"
touch "${tempdir}/mountdir/copy_dir/inner_dir/file"
cd "${tempdir}/mountdir/"
umount -l "${tempdir}/mountdir/"
mount -o loop "${tempdir}/test-disk.img" "${tempdir}/mountdir"
cp -Ra --no-preserve=ownership "${tempdir}"/mountdir/copy_dir/* 
"${tempdir}/mountdir/" || true
umount -l "${tempdir}/mountdir/"
cd "${cwd}"
rm -rf "${tempdir}"
The above script produces the following error from the cp:
cp: failed to get current directory No such file or directory (os error 2)
Despite the cp not needing to get or use the current directory and all paths 
being absolute. The script runs fine with gnu cp. 

I'll open an upstream issue if one doesn't already exist and we will
discuss how to work around it in the systemd script.

** Also affects: rust-coreutils (Ubuntu)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2165886

Title:
  "lxc shell" fails for stonking vm after atp upgrade

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lxd-agent-loader/+bug/2165886/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to