(maint) Use timeout builtin to TCPSocket when opening sockets.

This commit is contained in:
isaac-hammes 2023-03-02 10:56:40 -08:00
parent 8344f89722
commit 60fe266c9e

View file

@ -540,12 +540,11 @@ module Vmpooler
}, },
kind: :client kind: :client
) do ) do
Timeout.timeout(timeout) do
target_host = host target_host = host
target_host = "#{host}.#{domain}" if domain target_host = "#{host}.#{domain}" if domain
span = OpenTelemetry::Trace.current_span span = OpenTelemetry::Trace.current_span
span.set_attribute('net.peer.name', target_host) span.set_attribute('net.peer.name', target_host)
sock = TCPSocket.new target_host, port sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
begin begin
yield sock if block_given? yield sock if block_given?
ensure ensure
@ -553,7 +552,6 @@ module Vmpooler
end end
end end
end end
end
def vm_ready?(vm_name, domain = nil) def vm_ready?(vm_name, domain = nil)
tracer.in_span("Vmpooler::API::Helpers.#{__method__}") do tracer.in_span("Vmpooler::API::Helpers.#{__method__}") do