-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use open socket method for opening socket
This commit updates pool manager to use a method for opening a socket instead of opening it directly from check_pending_vm. Support is added for specifying the domain of the VM to connect to, which lays the groundwork for doing away with the assumption of having DNS search domains set for vmpooler to move VMs to the ready state.
- Loading branch information
Showing
1 changed file
with
5 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,10 @@ def check_pending_vm(vm, pool, timeout, vsphere) | |
|
||
def open_socket(host, domain=nil, timeout=5, port=22) | ||
Timeout.timeout(timeout) do | ||
target_host = vm | ||
target_host = "#{vm}.#{domain}" if domain | ||
TCPSocket.new target_host, port | ||
target_host = host | ||
target_host = "#{host}.#{domain}" if domain | ||
sock = TCPSocket.new target_host, port | ||
sock | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mattkirby
Author
Contributor
|
||
end | ||
end | ||
|
||
|
@@ -39,9 +40,7 @@ def _check_pending_vm(vm, pool, timeout, vsphere) | |
|
||
if host | ||
begin | ||
Timeout.timeout(5) do | ||
TCPSocket.new vm, 22 | ||
end | ||
open_socket vm | ||
move_pending_vm_to_ready(vm, pool, host) | ||
rescue | ||
fail_pending_vm(vm, pool, timeout) | ||
|
When are these sockets closed? Are we leaking file descriptors? (not new in this PR, just commenting on existing behavior). Since we're just testing if the other end is reachable, we probably want to do something like this: