Bug 1520373

Summary: Systemd does not start the log pipe from environment file
Product: Red Hat Enterprise Linux 9 Reporter: Marc Muehlfeld <mmuehlfe>
Component: 389-ds-baseAssignee: LDAP Maintainers <idm-ds-dev-bugs>
Status: NEW --- QA Contact: LDAP QA Team <idm-ds-qe-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 9.1CC: idm-ds-dev-bugs, mreynolds, nkinder, pasik, spichugi, tbordaz, vashirov, vmishra, ypismerov
Target Milestone: rcKeywords: Triaged
Target Release: 9.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: sync-to-jira
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Documentation from the RHDS Admin Guide none

Description Marc Muehlfeld 2017-12-04 11:25:15 UTC
Description of problem:
If you add a log pipe script to the /etc/sysconfig/dirsrv-instance_name config file as described in our documentation, systemd does not start the log pipe if you start RHDS.



Version-Release number of selected component (if applicable):
389-ds-base-1.3.6.1-21.el7_4.x86_64



How reproducible:
Always.



Steps to Reproduce:
1. # systemctl stop dirsrv.target
2. # rm /var/log/dirsrv/slapd-instance/access
3. Append to /etc/sysconfig/dirsrv-instance_name:
   python /usr/bin/ds-logpipe.py /var/log/dirsrv/slapd-instance/access -m 1000 -u dirsrv -s /var/run/dirsrv/slapd-instance.pid
4. # systemctl start dirsrv.target



Actual results:
Systemd does not run the command(s) in the /etc/sysconfig/dirsrv-instance_name file to start the log pipe.



Expected results:
Log pipe script should work as expected.



Additional info:
Manually starting the log pipe script instead of adding it to the /etc/sysconfig/dirsrv-instance_name file works.

Comment 1 Marc Muehlfeld 2017-12-04 12:06:21 UTC
Created attachment 1362652 [details]
Documentation from the RHDS Admin Guide

Because this does not work at the moment, I removed the
> 19.5. Replacing Log Files with a Named Pipe
section from the RHDS Admin Guide (BZ#1504764).

In case you need the documentation to reproduce the problem, I attached a PDF version of the section to this BZ.

Comment 5 Viktor Ashirov 2023-07-14 10:42:55 UTC
logpipe works with the following configuration:

1. Edit systemd service for the instance:
# systemctl edit --full  dirsrv@localhost

Add in [Unit] section:
Wants=dirsrv-logpipe@.service


2. Create a new unit file for ds-logpipe (access, error and audit logs should all have separate services) 
# cat > /usr/lib/systemd/system/dirsrv-logpipe@.service << EOF
[Unit]
Description=389 Directory Server Logpipe %i.
PartOf=dirsrv.target
Before=dirsrv@.service

[Service]
Type=simple
NotifyAccess=all
PIDFile=/run/dirsrv/slapd-%i-logpipe.pid
ExecStart=/usr/bin/python /usr/bin/ds-logpipe.py /var/log/dirsrv/slapd-%i/access.pipe -m 1000 -u dirsrv -s /run/dirsrv/slapd-%i.pid

[Install]
WantedBy=multi-user.target
EOF

3. Reload systemd and enable new service
# systemctl daemon-reload
# systemctl enable dirsrv-logpipe@localhost

4. Update settings for access log so that pipe file won't expire and won't be rotated:
# dsconf localhost config replace nsslapd-accesslog-maxlogsperdir=1
# dsconf localhost config replace nsslapd-accesslog-logexpirationtime=-1
# dsconf localhost config replace nsslapd-accesslog-logrotationtime=-1
# dsconf localhost config replace nsslapd-accesslog=/var/log/dirsrv/slapd-localhost/access.pipe
# dsconf localhost config replace nsslapd-accesslog-logbuffering=off

5. Stop dirsrv and remove /var/log/dirsrv/slapd-localhost/access.pipe created by dirsrv (it will be recreated by the dirsrv-logpipe service)
# systemctl stop dirsrv@localhost
# rm -f /var/log/dirsrv/slapd-localhost/access.pipe

6. Start dirsrv service, with the changes above it should automatically pick up new service and start it:
# systemctl start dirsrv@localhost
# ps -ef | grep [s]lapd
dirsrv      7335       1  0 06:32 ?        00:00:00 /usr/bin/python /usr/bin/ds-logpipe.py /var/log/dirsrv/slapd-localhost/access.pipe -m 1000 -u dirsrv -s /run/dirsrv/slapd-localhost.pid
dirsrv      7346       1  2 06:32 ?        00:00:00 /usr/sbin/ns-slapd -D /etc/dirsrv/slapd-localhost -i /run/dirsrv/slapd-localhost.pid


And the logpipe service is automatically stopped when the instance is stopped too:
# systemctl stop dirsrv@localhost
# ps -ef | grep [s]lapd -c
0


I think we can ship these systemd unit files as part of our rpm, but I have doubts if we should do this because of how obscure this feature is. But maybe if we add back documentation for it and ship these files, it would become more popular :) Also, some ds tools rely on log files being actual files and not pipes (for example healthcheck hangs trying to read log files), so we would need to add more changes and do more testing for a feature that is used very little.

Comment 7 Viktor Ashirov 2023-08-04 07:25:50 UTC
An alternative to logpipe is to use log buffering for all log types: https://github.com/389ds/389-ds-base/issues/5842.
Moving to 9.4 for now.