Bug 1508944 - [RFE] Add support for connect timeout
Summary: [RFE] Add support for connect timeout
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine-sdk-ruby
Classification: oVirt
Component: Core
Version: 4.1.9
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-4.1.8
: 4.1.10
Assignee: Juan Hernández
QA Contact: Radim Hrazdil
URL:
Whiteboard:
Depends On:
Blocks: 1448065
TreeView+ depends on / blocked
 
Reported: 2017-11-02 14:35 UTC by Juan Hernández
Modified: 2017-12-11 16:28 UTC (History)
2 users (show)

Fixed In Version: 4.1.10
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-12-11 16:28:49 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-4.1?
rhrazdil: testing_plan_complete-
rule-engine: planning_ack?
rule-engine: devel_ack+
pstehlik: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 83545 0 master MERGED Add `connect_timeout` parameter 2017-11-03 10:08:36 UTC
oVirt gerrit 83573 0 sdk_4.1 MERGED Add `connect_timeout` parameter 2017-11-03 10:24:55 UTC

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.


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