[Bug 1575572] Re: apache2 fails to start if installed via cloud config (on Xenial)
Steve Langasek
steve.langasek at canonical.com
Thu Apr 28 18:34:27 UTC 2016
> The problem seems to be that any package install during systemd boot of
> a package that only provides sysvinit scripts will fail. Reading invoke-rc.d,
> i'm not really sure why a proper systemd service woudlnt fail also.
The RUNLEVELHELPER check is buggy, yes. However, the behavior of
invoke-rc.d is by design; if the runlevel can't be determined (which
according to systemd it still would not be, even if the bug in invoke-
rc.d was fixed), invoke-rc.d should default to doing nothing because
there's no system policy to say whether the service should be started.
I think there's a case to be made that this is a bug in systemd, for
returning 'unknown' for the runlevel in these cases. The historical
behavior of sysvinit is that everything triggered from /etc/init.d/rc
inherits the value of the current runlevel in the RUNLEVEL environment
variable; and running e.g. 'RUNLEVEL=2 runlevel' - including on systemd
- will report this env value as the target runlevel.
$ runlevel
N 5
$ PREVLEVEL=5 RUNLEVEL=2 runlevel
5 2
$
Unless cloud-init is being called so early in boot that the runlevel
target is not known - which seems very unlikely - then I think the
correct thing for systemd to do is to honor this historical behavior by
making the 'runlevel' command return the target runlevel when called
from a systemd unit that's run at boot, even if that target has not yet
been reached. Opening a task on systemd for this.
Note, BTW, that the above also suggests a workaround for cloud-init to
employ. If for whatever reason systemd will not set itself up to return
the proper runlevel value, cloud-init can simply set RUNLEVEL=2 in the
environment prior to calling dpkg, and invoke-rc.d will pick this up and
DTRT with it.
** Also affects: systemd (Ubuntu)
Importance: Undecided
Status: New
** Changed in: systemd (Ubuntu)
Importance: Undecided => High
** Changed in: systemd (Ubuntu)
Status: New => Triaged
** Changed in: systemd (Ubuntu)
Assignee: (unassigned) => Martin Pitt (pitti)
** Changed in: init-system-helpers (Ubuntu)
Importance: High => Low
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/1575572
Title:
apache2 fails to start if installed via cloud config (on Xenial)
Status in cloud-init package in Ubuntu:
Confirmed
Status in init-system-helpers package in Ubuntu:
Confirmed
Status in systemd package in Ubuntu:
Triaged
Bug description:
Using the following cloud config, apache2 will fail to start on
installation on Xenial:
#cloud-config
packages:
- apache2
See for example:
$ gcloud compute instances create xenial-$(date +%y%m%d-%H%M) --image ubuntu-1604-xenial-v20160420c --image-project ubuntu-os-cloud --metadata-from-file user-data=cloud-config
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
xenial-160427-1050 europe-west1-d n1-standard-1 10.240.0.7 104.155.86.94 RUNNING
$ ssh ubuntu at 104.155.86.94 systemctl status apache2.service
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1575572/+subscriptions
More information about the foundations-bugs
mailing list