Open matthiasr opened 7 years ago
cc @srenatus
@matthiasr Thanks for reporting this! The files in init/
shouldn't be wrapper scripts at all, but rather symlinks to the internal sv
:
vagrant@api:~$ ls -al /opt/opscode/init/
total 8
drwxrwxr-x 2 root root 4096 Mar 27 15:08 .
drwxrwxr-x 8 root root 4096 Mar 27 15:05 ..
lrwxrwxrwx 1 root root 28 Mar 27 15:07 bookshelf -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:08 nginx -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:07 oc_bifrost -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:07 oc_id -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:08 opscode-chef-mover -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:07 opscode-erchef -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:07 opscode-expander -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:07 opscode-solr4 -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:07 postgresql -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:06 rabbitmq -> /opt/opscode/embedded/bin/sv
lrwxrwxrwx 1 root root 28 Mar 27 15:08 redis_lb -> /opt/opscode/embedded/bin/sv
If you are seeing those files as scripts, would you mind sharing:
There must be another piece to this puzzle.
The nginx
one is
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: initscript for runit-managed nginx service
### END INIT INFO
# Author: Chef Software, Inc. <cookbooks@chef.io>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="runit-managed nginx"
NAME=nginx
RUNIT=/usr/bin/sv
SCRIPTNAME=/etc/init.d/$NAME
# Exit if runit is not installed
[ -x $RUNIT ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
$RUNIT start $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
$RUNIT stop $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
status)
$RUNIT status $NAME && exit 0 || exit $?
;;
reload)
[ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME"
$RUNIT reload $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
force-reload)
[ "$VERBOSE" != no ] && log_daemon_msg "Force reloading $DESC" "$NAME"
$RUNIT force-reload $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
restart)
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
$RUNIT restart $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|restart}" >&2
exit 3
;;
esac
:
It's possible we did / are doing something wrong while upgrading between Chef Server versions …
The test server I'm investigating on is on package version 12.7.0-1, on Debian Jessie. I'm upgrading it to 12.13 now. I'll also try with a fresh install.
Upgrading from 12.7 to 12.13 using the proper procedure (stop, upgrade, start, cleanup) doesn't change anything about these files.
… and if I move aside one of the init scripts, then a chef-server-ctl reconfigure
faithfully recreates it.
This seems to come from here. I understand why that is, we use an old hacked-up version of the runit cookbook ourselves and Debian is very unhappy about symlinks to binaries in /etc/init.d
. It's just problematic that omnibus-ctl assumes otherwise …
so, this is only a problem on Debian, but it is a problem on Debian.
Is there a reason omnibus-ctl needs to execute init/<service> <command>
rather than embedded/bin/sv <service> <command>
?
We are currently on this version of the runit cookbook in chef-server, where the path to runit is hardcoded:
https://github.com/chef-cookbooks/runit/blob/v1.6.0/templates/debian/init.d.erb#L16
However, on newer versions, this appears to be configurable:
https://github.com/chef-cookbooks/runit/blob/master/templates/debian/init.d.erb#L16
So one option might be to upgrade the version of runit we are using.
Is there a reason omnibus-ctl needs to execute init/
rather than embedded/bin/sv ?
As long as we provide compatible output (as to not break any monitoring), I don't see a reason we couldn't use sv
directly.
In the sort term, maybe the easiest thing is to have omnibus-ctl set SVDIR to the "correct" value
I'm pretty sure with the symlink sv
itself behaves the same way, and produces the same output.
Yes, setting SVDIR "correctly" would work, but it still relies on the system runit actually being sane then. It probably will be, but it's still leaking in.
As expected from the runit_service
provider, the same happens on a clean install, so it's not related to any upgrade issues.
I'm wondering, but have no quick way to check, whether this works at all on Debian unless a system-wide runit
package is installed?
@matthiasr My assumption from the code is that it does not work on debian currently without runit installed on the system (outside of the chef-server package)
Quickly testing this in a minimal VM supports this. I think changing this to use the internal sv
binary directly is easy enough, I'll try to make a PR for that. It's not the cleanest solutions – the broken init files still exist, but they would no longer be actually used.
Done now: #54
We've merged https://github.com/chef/omnibus-ctl/pull/55 which will hopefully keep debian working provided you have runit available on the system. I'm going to leave this open, however, since we still depend on system-installed runit.
I updated the title to reflect that the leaking in is what makes it work in the first place.
Break-out from #52.
We use system-wide runit for various other daemons on our nodes.
chef-server-ctl reconfigure
works correctly, but to usechef-server-ctl restart
orchef-server-ctl status
we need to explicitly set SVDIR (which #52 will prevent).This is on Chef server 12.7 and 12.13 (same effect on both).
Digging into the code, the shell-out happens here. It does not call the
embedded/bin/sv
binary but wrapper scripts ininit/
, and these containRUNIT=/usr/bin/sv
which is the global binary, looking for the services in/etc/service
.I don't know why these wrapper scripts are necessary, how they are created, or whether they should be used at all?