This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 718183 - Provide native systemd unit file
Provide native systemd unit file
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: net-snmp (Show other bugs)
16
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jan Safranek
Fedora Extras Quality Assurance
:
: 695584 (view as bug list)
Depends On:
Blocks: SysVtoSystemd
  Show dependency treegraph
 
Reported: 2011-07-01 06:12 EDT by Jóhann B. Guðmundsson
Modified: 2011-08-22 11:02 EDT (History)
1 user (show)

See Also:
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 11:02:43 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Native systemd service file for snmp (301 bytes, text/plain)
2011-07-01 06:12 EDT, Jóhann B. Guðmundsson
no flags Details
Native systemd service file for snmptrap (305 bytes, text/plain)
2011-07-01 06:13 EDT, Jóhann B. Guðmundsson
no flags Details

  None (edit)
Description Jóhann B. Guðmundsson 2011-07-01 06:12:10 EDT
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 06:12:59 EDT
Created attachment 510838 [details]
Native systemd service file for snmp
Comment 3 Jan Safranek 2011-08-03 08:20:14 EDT
*** Bug 695584 has been marked as a duplicate of this bug. ***
Comment 4 Jan Safranek 2011-08-04 08:38:16 EDT
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 09:05:03 EDT
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 09:13:49 EDT
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 09:40:28 EDT
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 08:20:38 EDT
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 08:27:22 EDT
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 17:53:23 EDT
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 19:01:39 EDT
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 04:39:54 EDT
Damn guidelines :). Thanks for heads up.
Comment 13 Fedora Update System 2011-08-11 04:58:59 EDT
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 00:22:41 EDT
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 11:02:33 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.