Skip to content

Set timeout for DNS resolution in UrlBlocker

What does this MR do?

If DNS resolution takes a very long time, an HTTP request can exceed its time limit - in some cases significantly.

Ruby 2.7 adds a timeout keyword argument to Addrinfo.getaddrinfo. We set that to the remaining time for the current request (if we're in a request), bounded by zero on the lower end (so we don't try to set a negative timeout), and five seconds on the upper end (as a reasonable maximum).

This timeout argument only works on systems with getaddrinfo_a available.

If the timeout is hit, Addrinfo.getaddrinfo raises a SocketError, which is already handled correctly.

For gitlab-com/gl-infra/scalability#562.

Merge request reports