Bug 1508944

Summary: [RFE] Add support for connect timeout
Product: [oVirt] ovirt-engine-sdk-ruby Reporter: Juan Hernández <juan.hernandez>
Component: CoreAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Radim Hrazdil <rhrazdil>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.9CC: bugs, lveyde
Target Milestone: ovirt-4.1.8Keywords: FutureFeature
Target Release: 4.1.10Flags: rule-engine: ovirt-4.1?
rhrazdil: testing_plan_complete-
rule-engine: planning_ack?
rule-engine: devel_ack+
pstehlik: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 4.1.10 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-11 16:28:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1448065    

Description Juan Hernández 2017-11-02 14:35:51 UTC
Currently the SDK supports a global timeout, for the complete execution of operations, but it doesn't support a timeout specific for connection establishment. This is very convenient to detect problems when using incorrect IP addresses, as otherwise the application always has to wait for the default TCP timeout.

The SDK should have a new `connect_timeout` parameter in the constructor.

Comment 1 Juan Hernández 2017-11-28 16:55:59 UTC
To verify select an IP address that can doesn't respond. The easy way is to use the "iptables" command to just make sure that the traffic to that IP address is dropped:

  # iptables --table filter --append OUTPUT --dest 192.168.122.100 --jump DROP

Then create a script that tries to use that IP address:

---8<---
require 'logger'
require 'ovirtsdk4'

# Create the connection to the server:
connection = OvirtSDK4::Connection.new(
  url: 'https://192.168.122.100/ovirt-engine/api',
  username: 'admin@internal',
  password: 'redhat123',
  insecure: true
)

# Test the connection:
connection.test(raise_exception: true)

# Close the connection:
connection.close
---8<---

This will fail, but it take several minutes, till the the TCP time-out expires.

Repeat the same adding the new `connect_timeout` parameter, for example setting it to 10 seconds:

---8<---
require 'logger'
require 'ovirtsdk4'

# Create the connection to the server:
connection = OvirtSDK4::Connection.new(
  url: 'https://192.168.122.100/ovirt-engine/api',
  username: 'admin@internal',
  password: 'redhat123',
  insecure: true,
  connect_timeout: 10
)

# Test the connection:
connection.test(raise_exception: true)

# Close the connection:
connection.close
---8<---

It should fail anyhow, but much earlier, after 10 seconds.

Comment 2 Radim Hrazdil 2017-11-28 21:38:31 UTC
Verified using method suggested by Juan, with connect_timeout parameter such request fails after given number of seconds. Used sdk version 4.2.0.beta2, RHVM 4.1.8.1.