Bug 718183 - Provide native systemd unit file
Summary: Provide native systemd unit file
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: net-snmp
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jan Safranek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 695584 (view as bug list)
Depends On:
Blocks: SysVtoSystemd
TreeView+ depends on / blocked
 
Reported: 2011-07-01 10:12 UTC by Jóhann B. Guðmundsson
Modified: 2011-08-22 15:02 UTC (History)
1 user (show)

Fixed In Version: net-snmp-5.7-6.fc16
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-08-22 15:02:43 UTC
Type: ---
Embargoed:


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

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.


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