Bug 1379565 - bkr.server.util.absolute_url() does a DNS lookup on every invocation, even when it doesn't need to
Summary: bkr.server.util.absolute_url() does a DNS lookup on every invocation, even wh...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: general
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: 23.3
Assignee: Dan Callaghan
QA Contact: tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-27 07:19 UTC by Dan Callaghan
Modified: 2016-11-07 06:44 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-07 06:44:41 UTC
Embargoed:


Attachments (Terms of Use)

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.


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