When run from systemd-nspawn, installation of mysql-server fails because postinst fails to shut down server
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mysql-5.7 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
systemd (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Creating a fresh Bionic directory with `debootstrap` and then attempting to install `mysql-server` inside a `systemd-nspawn` container fails with the following message:
Setting up mysql-server-5.7 (5.7.21-1ubuntu1) ...
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ]
update-
Renaming removed key_buffer and myisam-recover options (if present)
Error: Unable to shut down server with process id 532
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
Steps to reproduce:
1. debootstrap bionic testmysql
2. rm testmysql/
2. systemd-nspawn -D testmyql --bind /etc/resolv.conf /bin/bash -c 'apt update && apt install mysql-server'
summary: |
- installation of mysql-server fails because postinst fails to shut down - server + When run from systemd-nspawn, installation of mysql-server fails because + postinst fails to shut down server |
my nspawn failed to reproduce this (probably too old on xenial), but doing the same in a chroot instead of systemd-nspawn works fine.
Setting up mysql-server-5.7 (5.7.21-1ubuntu1) ... alternatives: using /etc/mysql/ mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode system/ multi-user. target. wants/mysql. service → /lib/systemd/ system/ mysql.service.
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ]
update-
Renaming removed key_buffer and myisam-recover options (if present)
Cannot open /proc/net/unix: No such file or directory
Cannot open /proc/mounts
Created symlink /etc/systemd/
So it seems to be something special to nspawn.
The code in the postinst that does this looks like that.
stop_server(){ mysqld. pid")
local tmpdir=$1
# Send kill signal
server_pid=$(cat "$tmpdir/
kill "$server_pid"
for i in $(seq 1 60); do
sleep 0.1 # A full second is too long, but we need to give the server _some_ time.
if ! $(ps $server_pid >/dev/null 2>&1); then
return 0
fi
sleep 1
done
# The server hasn't shut down in a timely manner
echo "Error: Unable to shut down server with process id $server_pid" >&2
return 1
}
So it essentially is "just" a kill and waiting until the pid is gone
Knowing that a few questions:
1. if you run an interactive bash in nspawn and do the same install would that work
2. if (1) is the same, then after the fail what is going on with the pid it failed on
2.1 any dmesg/syslog entries about it?
2.2 if you send a kill manually what happens?
2.3 is the process in any odd state (a full ps axlf from inside the nspawn might be useful)
Setting up a bionic to check the nspawn there ...