Bug 750554

Summary: Snmpd might need DNS to be started first
Product: [Fedora] Fedora Reporter: Göran Uddeborg <goeran>
Component: net-snmpAssignee: Jan Safranek <jsafrane>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: jsafrane
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-07 11:30:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Göran Uddeborg 2011-11-01 15:03:08 UTC
Description of problem:
A snmpd configuration can contain names that needs DNS name resolution.  If
snmpd and the DNS server runs on the same host, the DNS server needs to be
started first.  But there is nothing enforcing this.  Which makes the snmpd server to fail on startup.

Version-Release number of selected component (if applicable):
net-snmp-5.7-6.fc16.x86_64

How reproducible:
Happened every time for me.  Since it is a kind of a race condition, I guess you could be lucky, and things could happen in the right order by chance.

Steps to Reproduce:
1. Configure the "agentaddress" in the snmpd configuration with a name defined in DNS.
2. Restart the system
  
Actual results:
Snmpd fails with an error message

    snmpd[1368]: getaddrinfo: mimmi.uddeborg Name or service not known
    snmpd[1368]: getaddrinfo("mimmi.uddeborg", NULL, ...): Name or service not known
    snmpd[1368]: Error opening specified endpoint "mimmi.uddeborg"
    snmpd[1368]: Server Exiting with code 1

Expected results:
The server should come up normally.

Additional info:
I've avoided the problem locally by adding "named.service" to the "After" line
in /lib/systemd/system/snmpd.service.  But since that file isn't marked as a
%config, this solution will not be persistent.  When I upgrade net-snmp, I will
have to (remember to) redo it.

Comment 1 Jan Safranek 2011-11-04 14:15:59 UTC
It's not net-snmp fault if someone (systemd) starts it without dns.

See http://www.freedesktop.org/wiki/Software/systemd/FrequentlyAskedQuestions for an easy way, how to use custom snmpd.service without rpm overwriting it in next update.

Comment 2 Göran Uddeborg 2011-11-04 20:45:02 UTC
> It's not net-snmp fault if someone (systemd) starts it without dns.

Eh?  If snmpd would want named to be started before it started itself, that would be up to snmpd to say, wouldn't it?  In particular, that belongs in snmpd.service, and that file belongs to net-snmp.

You can certainly argue that it is unusual for snmpd to depend on named, and thus it should not wait for it by default.  That is a judgement you as a package maintainer is the one to do.  Then you can close this bugzilla.

But IF you would have thought it made sense for snmpd to wait for named, THEN that declaration would have belonged to the net-snmp package.

> See http://www.freedesktop.org/wiki/Software/systemd/FrequentlyAskedQuestions
> for an easy way ...

Ok, copying to /etc is the recommended rule.  I will have to add some monitoring, to detect if the distributed file gets some other change, so I can update my local copy in the same way.  Not as convenient as a %config-marked file.  But I can manage that, no problem.

Comment 3 Jan Safranek 2011-11-07 11:30:56 UTC
(In reply to comment #2)
> > It's not net-snmp fault if someone (systemd) starts it without dns.
> 
> Eh?  If snmpd would want named to be started before it started itself, that
> would be up to snmpd to say, wouldn't it?  In particular, that belongs in
> snmpd.service, and that file belongs to net-snmp.
>
> You can certainly argue that it is unusual for snmpd to depend on named, and
> thus it should not wait for it by default.  That is a judgement you as a
> package maintainer is the one to do.  Then you can close this bugzilla.

Typically, snmpd does not depend on named. Default snmpd.conf does not have any DNS references. In addition, I'd guess vast majority of snmpd installations runs on system without named service and with external DNS server.

In the same way you could request snmptrapd.service to depend on mysql.service, because one *could* configure snmptrapd to send traps to database. But it's not typical use case.

With the old initscripts we had simple linear ordering, which solved these cases, now with parallel boot this responsibility moves to admin.

> 
> But IF you would have thought it made sense for snmpd to wait for named, THEN
> that declaration would have belonged to the net-snmp package.
> 
> > See http://www.freedesktop.org/wiki/Software/systemd/FrequentlyAskedQuestions
> > for an easy way ...
> 
> Ok, copying to /etc is the recommended rule.  I will have to add some
> monitoring, to detect if the distributed file gets some other change, so I can
> update my local copy in the same way.  Not as convenient as a %config-marked
> file.  But I can manage that, no problem.

Maybe there is easier way: http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F

(yes, systemd documentation/knowledge is a bit scattered... we're all learning it)

Comment 4 Göran Uddeborg 2011-11-07 20:06:08 UTC
So there is an include feature!  That feels much better than copying and editing.

We are indeed all learning.  I am, for sure!  Thanks for the pointer. :-)