Issue #23351 has been reported by Sam Morris. ---------------------------------------- Bug #23351: systemd service provider thinks 'activating' services are inactive https://projects.puppetlabs.com/issues/23351
* Author: Sam Morris * Status: Unreviewed * Priority: Normal * Assignee: * Category: service * Target version: * Affected Puppet version: 2.7.23 * Keywords: systemd * Branch: ---------------------------------------- I have a systemd service that, when started, takes a few seconds before failing to start. Systemd is configured to restart the service when it fails to start, so when you look at the output of 'systemctl status' you see: vagrant@pipeline:~$ systemctl status hadoop-hdfs-secondarynamenode.service hadoop-hdfs-secondarynamenode.service - Hadoop secondarynamenode Loaded: loaded (/etc/systemd/system/hadoop-hdfs-secondarynamenode.service; disabled) Active: activating (start) since Wed 2013-12-04 14:05:50 UTC; 3s ago Control: 27702 (sudo) CGroup: name=systemd:/system/hadoop-hdfs-secondarynamenode.service ├─27702 sudo -E -u hdfs /bin/bash -c cd /var/lib/hadoop-hdfs && /usr/lib/hadoop/sbin/hadoop-d... ├─27709 /bin/bash -c cd /var/lib/hadoop-hdfs && /usr/lib/hadoop/sbin/hadoop-daemon.sh --confi... ├─27710 bash /usr/lib/hadoop/sbin/hadoop-daemon.sh --config /etc/hadoop/conf start secondaryn... └─27767 sleep 3 In my Puppet manifest, I've got: service{'hadoop-hdfs-secondarynamenode.service': ensure => stopped, enable => false, provider => systemd, } However, applying the manifest does not result in the service being stopped. This appears to be due to the following: $ systemctl is-active hadoop-hdfs-secondarynamenode.service; echo $? activating 3 i.e., service.rb thinks the service is stopped, because the systemctl command 'failed' (returned non-zero). In practice, systemd units can be in any of the following states, taken from <http://cgit.freedesktop.org/systemd/systemd/tree/src/core/unit.h#n46>: enum UnitActiveState { UNIT_ACTIVE, UNIT_RELOADING, UNIT_INACTIVE, UNIT_FAILED, UNIT_ACTIVATING, UNIT_DEACTIVATING, _UNIT_ACTIVE_STATE_MAX, _UNIT_ACTIVE_STATE_INVALID = -1 }; The code for `systemctl is-active` code to look at is at <http://cgit.freedesktop.org/systemd/systemd/tree/src/systemctl/systemctl.c#n2391>. In brief, the command exits with status 0 only if the state is UNIT_ACTIVE or UNIT_RELOADING; otherwise it exits with status 3 (to indicate that the service is "not running"). IMO puppet should look at the output of 'systemctl is-active SERVICENAME', and if the output is 'active', 'reloading' or 'activating', it should consider the service to be running. If you are happy with that change, I'll implement it and send you a patch. -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/groups/opt_out.