Bug 1379565

Summary: bkr.server.util.absolute_url() does a DNS lookup on every invocation, even when it doesn't need to
Product: [Retired] Beaker Reporter: Dan Callaghan <dcallagh>
Component: generalAssignee: Dan Callaghan <dcallagh>
Status: CLOSED CURRENTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: dcallagh, dowang, mjia, rjoost
Target Milestone: 23.3Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-07 06:44:41 UTC 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:

Description Dan Callaghan 2016-09-27 07:19:51 UTC
We hit a problem today where the Beaker test suite is timing out because DNS lookups are occasionally taking longer than normal.

It turns out bkr.server.util.absolute_url() is calling socket.getfqdn() (which involves a DNS query) on every invocation. We use that function a lot, including when sending mails and when generating atom feeds and many other places too.

We should optimise it to avoid any socket.get* calls if the hostname has been configured, and to just use the result of socket.gethostname() if that appears to be fully qualified (it is in all our environments, although it's not guaranteed by Linux to be fully qualified in general) to avoid making DNS queries unless absolutely necessary.

Comment 1 Dan Callaghan 2016-09-28 03:59:34 UTC
http://gerrit.beaker-project.org/5276

Comment 2 Dan Callaghan 2016-09-28 04:02:17 UTC
I considered making absolute_url() cache the hostname on first invocation but I figured that would be annoying and surprising behaviour for the sysadmin (hostname changes would not be reflected in Beaker until httpd and beakerd are restarted).

Comment 5 Dan Callaghan 2016-11-07 06:44:41 UTC
Beaker 23.3 has been released.