Jira (PUP-10378) 'puppet resource service' does not return all active services on Ubuntu

26 views
Skip to first unread message

Michael Smith (Jira)

unread,
Mar 19, 2020, 7:09:03 PM3/19/20
to puppe...@googlegroups.com
Michael Smith created an issue
 
Puppet / Bug PUP-10378
'puppet resource service' does not return all active services on Ubuntu
Issue Type: Bug Bug
Affects Versions: PUP 6.14.0
Assignee: Unassigned
Components: Types and Providers
Created: 2020/03/19 4:08 PM
Priority: Normal Normal
Reporter: Michael Smith

Puppet Version: 6.14.0
Puppet Server Version: whatever's in PE 2019.5.0
OS Name/Version: Ubuntu 18.04.4

$ puppet resource service pe-postgresql
service { 'pe-postgresql':
  ensure   => 'running',
  enable   => 'true',
  provider => 'systemd',
}
$ puppet resource service | grep pe-postgresql
$ 

Desired Behavior:

pe-postgresql should be listed when listing all services, because it definitely exists.

Actual Behavior:

Seems to be omitted. Some related debugging

systemctl list-unit-files --type service --full | grep pe-postgresql
pe-postgresql.service                  bad
pe-postgresql11.service                static
pe-postgresql96.service                static

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Mar 19, 2020, 7:56:04 PM3/19/20
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 24, 2020, 7:45:02 AM3/24/20
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 31, 2020, 10:57:03 AM3/31/20
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Apr 1, 2020, 4:46:04 AM4/1/20
to puppe...@googlegroups.com

Luchian Nemes (Jira)

unread,
Apr 3, 2020, 4:08:03 AM4/3/20
to puppe...@googlegroups.com

Luchian Nemes (Jira)

unread,
Apr 7, 2020, 12:33:04 PM4/7/20
to puppe...@googlegroups.com
Luchian Nemes commented on Bug PUP-10378
 
Re: 'puppet resource service' does not return all active services on Ubuntu

When puppet is listing information about a single service (in our case via puppet resource service pe-postgresql), it will get it's data from the systemd provider, through the statuscmd (:ensure field) and enabled? (:enable field) methods. Then it will output:

service { 'pe-postgresql':
   ensure   => 'running',
   enable   => 'true',
   provider => 'systemd', 
}

 

When puppet is listing all the available services (via puppet resource service), systemctl is queried, through the instances method, to gather all the services. These are filtered and only the ones with any of the following states are shown to the user: `disabled`, `enabled`, `masked` or `indirect`. Since in our case pe-postgresql is marked as bad, it is indeed omitted. 

 

systemctl's man section for the is-enabled parameter possible statuses states that:

Name Description Error code
"bad" The unit file is invalid or another error occurred. Note that is-enabled will not actually return this state, but print an error message instead. However the unit file listing printed by list-unit-files might show it. > 0

 

Puppet will simply ignore the error message described above and will decide that a service is not enabled. In case of debian based operating systems, which is our current case with Ubuntu, it will further check and find out that the service is indeed well and actually enabled.

 

Steps taken in investigating why that is the only service marked as bad:

Running `systemctl list-unit-files pe-postgre*` shows our pe-postgresql services available on the system:

 

pe-postgresql.service          bad
pe-postgresql11.service      static

 

 

By running `systemctl status pe-postgresql`, we got the service’s status, unit file and conf file:

pe-postgresql.service - Puppet Enterprise PostgreSQL database server
  Loaded: loaded (/lib/systemd/system/pe-postgresql.service; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/pe-postgresql.service.d
           └─pe-postgresql.conf

 

 

When checking the conf file, we found out that it actually is a symlink.

 

> ls -l /lib/systemd/system/pe-postgresql.service.d/pe-postgresql.conf
pe-postgresql.service.d/pe-postgresql.conf -> /etc/alternatives/pe-postgresql-server-service

 

 

And when checking the destination, it turned out to be another symlink, pointing towards the pe-postgresql11 service:

 

> ls -l /etc/alternatives/pe-postgresql-server-service
/etc/alternatives/pe-postgresql-server-service -> /lib/systemd/system/pe-postgresql11.service.d/pe-postgresql11.conf

 

 

Getting rid of the symlink chain and replacing it with a copy of pe-postgresql11.conf seems to be a solution:

> cp --remove-destination -d /lib/systemd/system/pe-postgresql11.service.d/pe-postgresql11.conf  /lib/systemd/system/pe-postgresql.service.d/pe-postgresql.conf

 

systemctl doesn't consider the pe-postgresql service as bad anymore:

 

> systemctl list-unit-files pe-postgre*
pe-postgresql.service         enabled
pe-postgresql11.service     static

 

 

Also puppet now shows it to the user:

 

> puppet resource service | grep pe-postgresql
service { 'pe-postgresql.service':

 

 

It seems that systemctl really hates symlinks. A related issue regarding this was found on systemd's github repository but the fix should already be included in the version we have on the Ubuntu systems. It's not clear yet how and by whom are those conf files created that way.

Luchian Nemes (Jira)

unread,
Apr 8, 2020, 3:51:04 AM4/8/20
to puppe...@googlegroups.com

Michael Smith (Jira)

unread,
Apr 8, 2020, 10:05:35 AM4/8/20
to puppe...@googlegroups.com

Ok, if it doesn't seem feasible to identify this in Puppet that's fine. We can focus on fixing the service in PE.

Luchian Nemes (Jira)

unread,
Apr 9, 2020, 11:31:03 AM4/9/20
to puppe...@googlegroups.com

Michael Smith, this is indeed feasible because it represents an inconsistency in puppet's behaviour, so I've opened a pull request which should fix this issue (and PE-28640). Also, we highly recommend using `puppet resource service <service_name>` where possible instead of `puppet resource service | grep <service_name>` since the time execution difference between querying for only the one specific service needed vs. all available services and then searching for the needed one is quite big (besides the obvious reasons, systemctl is slow when retrieving the list of all the services available on the system).

Mihai Buzgau (Jira)

unread,
Apr 15, 2020, 3:34:04 AM4/15/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2020-04-15 , NW - 2020-04-29

Gabriel Nagy (Jira)

unread,
Apr 21, 2020, 4:34:03 AM4/21/20
to puppe...@googlegroups.com

Luchian Nemes (Jira)

unread,
Apr 21, 2020, 9:46:03 AM4/21/20
to puppe...@googlegroups.com
Luchian Nemes updated an issue
Change By: Luchian Nemes
Release Notes: Bug Fix
Release Notes Summary: Consistency fix in puppet's behaviour when listing information about a single specific service and all available ones by showing services in a 'bad' state in both cases.

Claire Cadman (Jira)

unread,
Apr 27, 2020, 6:54:04 AM4/27/20
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Jul 2, 2020, 6:00:03 AM7/2/20
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages