Difference between revisions of "Upstart issues"

From Linux-VServer

Jump to: navigation, search
(fake low level events inside the guest)
(added "Init procedure doesn't complete")
Line 98: Line 98:
  
 
For more information see the man pages of <code>getpid(2)</code> (NOTES) and <code>clone(2)</code> (BUGS).
 
For more information see the man pages of <code>getpid(2)</code> (NOTES) and <code>clone(2)</code> (BUGS).
 +
 +
=== Init procedure doesn't complete ===
 +
If you've completed all above steps and some init scripts doesn't get invoked at all (most notably old SYSV init scripts) you might have encountered same error that I did.
 +
In Lucid guest I had to comment out following line in /etc/init/ssh.conf:
 +
  # replaces SSHD_OOM_ADJUST in /etc/default/ssh
 +
  oom never
 +
to
 +
  # replaces SSHD_OOM_ADJUST in /etc/default/ssh
 +
  #oom never
 +
 +
 +
After commenting out this line initialization completed successfully.

Revision as of 10:36, 6 July 2010

Contents

running an upstart based guest

currently upstart based guests need some manual tweaking to make them work inside a vserver guest.

prepare the host

First of all you need to set the init style of your vserver to plain

# echo plain > /etc/vservers/<vservername>/apps/init/style

I'd also strongly recommend to mount /var/run and /var/lock of the guest as tmpfs. So add the following lines to /etc/vservers/<vservername>/fstab

none    /var/run        tmpfs   size=16m,nosuid,mode=0755       0 0
none    /var/lock       tmpfs   size=16m,noexec,nosuid,nodev    0 0

remove low level services inside the guest

Then you need to get rid of anything in /etc/init/ that tries to fiddle with your Server's Hardware or other low-level Stuff that's already handled by your host's kernel/system. Having one such scriptlet still enabled might cause the whole upstart system to fail (like not beeing able to open /dev/console or failing to start the udev system). Just remove these scriptlets, move them out of the way or rename them to something not ending in .conf. Be aware that upstart also parses subfolders of /etc/init/ for .conf files.

This is what I deleted on a basic Ubuntu 9.10 guest:

dmesg.conf
hostname.conf
hwclock-save.conf
hwclock.conf
mountall-net.conf
mountall-reboot.conf
mountall-shell.conf
mountall.conf
network-interface.conf
networking.conf
procps.conf
rsyslog-kmsg.conf
tty1.conf
tty2.conf
tty3.conf
tty4.conf
tty5.conf
tty6.conf
upstart-udev-bridge.conf

fake low level events inside the guest

Finally you need to fake emit the events that some of these scripts would do during regular boot. Probably the cleanest approach is to add a scriptlet vserver.conf to /etc/init/ with this content:

start on startup
script
       touch /var/run/utmp
       chown root:utmp /var/run/utmp
       chmod 664 /var/run/utmp
       initctl emit virtual-filesystems
       initctl emit local-filesystems
       initctl emit remote-filesystems
       initctl emit filesystem
end script

The utmp stuff is needed if you mount /var/run as tmpfs and you don't create utmp anywhere else.

adapt /etc/init/rc-sysinit.conf inside the guest

This depends on net-device-up IFACE=lo, remove this from the start line so that it reads:
start on filesystem

This scriptlet tries to parse /proc/cmdline which will not work and probably isn't needed inside a vserver.
Simply comment out or delete the whole for ARG in $(cat /proc/cmdline) do...done loop.

Notes for older kernels

If you encounter upstart errors like this:

$ vserver foo start
init: missing runlevel
Try `init --help' for more information.

or

$ vserver foo start
telinit: Failed to connect to socket /com/ubuntu/upstart: Connection refused

then you're probably running the current stable version 2.6.22.19-vs2.2.0.7.

Upstart's /sbin/init implementation requires to be PID 1. It is linked against NPTL (in contrast to sysvinit), which has a bug in it's caching getpid(2) wrapper. With this kernel version getpid(2) returns the cached PID to init, resulting in init replacing itself with telinit. You can fix this by upgrading to a 2.6.26+ kernel and a newer vserver patch, or by patching upstart:

diff --git a/init/main.c b/init/main.c
index bfcd528..c6c9304 100644
--- a/init/main.c
+++ b/init/main.c
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
+#include <syscall.h>
 
 #include <linux/kd.h>
 
@@ -131,7 +132,7 @@ main (int   argc,
 	}
 
 	/* Check we're process #1 */
-	if (getpid () > 1) {
+	if (syscall(SYS_getpid) > 1) {
 		execv (TELINIT, argv);
 		/* Ignore failure, probably just that telinit doesn't exist */

For more information see the man pages of getpid(2) (NOTES) and clone(2) (BUGS).

Init procedure doesn't complete

If you've completed all above steps and some init scripts doesn't get invoked at all (most notably old SYSV init scripts) you might have encountered same error that I did. In Lucid guest I had to comment out following line in /etc/init/ssh.conf:

 # replaces SSHD_OOM_ADJUST in /etc/default/ssh
 oom never

to

 # replaces SSHD_OOM_ADJUST in /etc/default/ssh
 #oom never


After commenting out this line initialization completed successfully.

Personal tools