Bug 718183

Summary: Provide native systemd unit file
Product: [Fedora] Fedora Reporter: Jóhann B. Guðmundsson <johannbg>
Component: net-snmpAssignee: Jan Safranek <jsafrane>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: jsafrane
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: net-snmp-5.7-6.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-22 15:02:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 713562    
Attachments:
Description Flags
Native systemd service file for snmp
none
Native systemd service file for snmptrap none

Description Jóhann B. Guðmundsson 2011-07-01 10:12:10 UTC
Description of problem:

https://fedoraproject.org/wiki/Features/SysVtoSystemd


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Jóhann B. Guðmundsson 2011-07-01 10:12:59 UTC
Created attachment 510838 [details]
Native systemd service file for snmp

Comment 3 Jan Safranek 2011-08-03 12:20:14 UTC
*** Bug 695584 has been marked as a duplicate of this bug. ***

Comment 4 Jan Safranek 2011-08-04 12:38:16 UTC
This turns out to be more complicated than simple .service file. Snmpd daemonizes itself in a way it confuses systemd. There can be (very short) time after main process exits and the .pid file is created by a forked child -> systemd assumes the service died and kills it.

I'll try to rewrite snmpd not to fork and to send notification to systemd after  initialization (via sd_notify). This will take some time though, especially passing it upstream.

Comment 5 Jóhann B. Guðmundsson 2011-08-04 13:05:03 UTC
Hum.. 

I'm unable to duplicate this both snmpd and snmptrapd service start and stop cleanly. 

Does this happen in some oddball cases just wondering if those service files wont suffice until the fix is brought in via update.

Comment 6 Jóhann B. Guðmundsson 2011-08-04 13:13:49 UTC
Would switching to Type=oneshot suffice as a workaround for this as in.. 

# snmpd.service 

[Unit]
Description=Simple Network Management Protocol (SNMP) Daemon.
After=syslog.target network.target

[Service]
Type=oneshot
EnvironmentFile=-/etc/sysconfig/snmpd
ExecStart=/usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

# snmptrapd.service

[Unit]
Description=Simple Network Management Protocol (SNMP) Trap Daemon.
After=syslog.target network.target

[Service]
Type=oneshot
EnvironmentFile=-/etc/sysconfig/snmptrapd
ExecStart=/usr/sbin/snmptrapd -Lsd -p /var/run/snmptrapd.pid
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Remembert to restart the daemon when testing this as in 

systemctl daemon-reload
systemctl stop snmpd.service snmptrapd.service 
systemctl start snmpd.service snmptrapd.service
systemctl status snmpd.service snmptrapd.service

Comment 7 Jan Safranek 2011-08-04 13:40:28 UTC
Problem is the snmpd service. It forks twice to detach from terminal as usual daemons do. But instead of the grand-parent to wait until everything initializes in the children (and return proper exit code), snmpd grand-parent exits immediately. The .pid file is written by the child of the second fork. And now we have a race - if systemd processes the parent process SIGCHLD *before* the child creates the pid file, systemd assumes the daemon is dead and kills everything.

This happens only sometimes and it took me some time to find out what is going on, systemd could log something on higher log level...

Anyway, as a workaround, I can use snmpd -f (= do not fork) and service type 'simple', but if there is some service depending on snmpd (like subagents), it could get started before snmpd creates its listening sockets, so I am adding support for 'notify' service type. The code is simple, still it requires some testing and pushing upstream....

Comment 8 Fedora Update System 2011-08-09 12:20:38 UTC
net-snmp-5.7-5.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/net-snmp-5.7-5.fc16

Comment 9 Jan Safranek 2011-08-09 12:27:22 UTC
Please test carefully... I've checked systemd integration into upstream git and patched F16 and rawhide packages. New Net-SNMP version will be released after F16 is out, so Fedora is a bit ahead, but it has always been on the bleeding edge :).

Comment 10 Fedora Update System 2011-08-09 21:53:23 UTC
Package net-snmp-5.7-5.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing net-snmp-5.7-5.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/net-snmp-5.7-5.fc16
then log in and leave karma (feedback).

Comment 11 Jóhann B. Guðmundsson 2011-08-10 23:01:39 UTC
Note that you forgot to drop the legacy sysv init script or package the legacy sysv init script in a separate sub package as stated by the guidelines ( follow links in comment 2 for details )

Comment 12 Jan Safranek 2011-08-11 08:39:54 UTC
Damn guidelines :). Thanks for heads up.

Comment 13 Fedora Update System 2011-08-11 08:58:59 UTC
net-snmp-5.7-6.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/net-snmp-5.7-6.fc16

Comment 14 Fedora Update System 2011-08-12 04:22:41 UTC
Package net-snmp-5.7-6.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing net-snmp-5.7-6.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/net-snmp-5.7-6.fc16
then log in and leave karma (feedback).

Comment 15 Fedora Update System 2011-08-22 15:02:33 UTC
net-snmp-5.7-6.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.