mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
Check if a hostname return is empty string
This commit checks whether a hostname returned is an empty string. Without this change a VM that returns a hostname with a empty string will report as having a hostname mismatch, which may happen before all VM data is updated.
This commit is contained in:
parent
4880ef1979
commit
6810cbe78e
1 changed files with 17 additions and 12 deletions
|
|
@ -134,23 +134,28 @@ module Vmpooler
|
|||
end
|
||||
end
|
||||
|
||||
check_hostname = pool['check_hostname_for_mismatch']
|
||||
check_hostname = $config[:config]['check_ready_vm_hostname_for_mismatch'] if check_hostname.nil?
|
||||
check_hostname = true if check_hostname.nil?
|
||||
if check_hostname
|
||||
# Check if the hostname has magically changed from underneath Pooler
|
||||
host = provider.get_vm(pool['name'], vm)
|
||||
if host['hostname'] != vm
|
||||
$redis.smove('vmpooler__ready__' + pool['name'], 'vmpooler__completed__' + pool['name'], vm)
|
||||
$logger.log('d', "[!] [#{pool['name']}] '#{vm}' has mismatched hostname, removed from 'ready' queue")
|
||||
return
|
||||
end
|
||||
end
|
||||
return if has_mismatched_hostname?(vm, pool, provider)
|
||||
|
||||
vm_still_ready?(pool['name'], vm, provider)
|
||||
end
|
||||
end
|
||||
|
||||
def has_mismatched_hostname?(vm, pool, provider)
|
||||
check_hostname = pool['check_hostname_for_mismatch']
|
||||
check_hostname = $config[:config]['check_ready_vm_hostname_for_mismatch'] if check_hostname.nil?
|
||||
return if check_hostname == false
|
||||
|
||||
# Check if the hostname has magically changed from underneath Pooler
|
||||
vm_hash = provider.get_vm(pool['name'], vm)
|
||||
hostname = vm_hash['hostname']
|
||||
|
||||
return if hostname.empty?
|
||||
return if hostname == vm
|
||||
$redis.smove('vmpooler__ready__' + pool['name'], 'vmpooler__completed__' + pool['name'], vm)
|
||||
$logger.log('d', "[!] [#{pool['name']}] '#{vm}' has mismatched hostname, removed from 'ready' queue")
|
||||
return true
|
||||
end
|
||||
|
||||
def check_running_vm(vm, pool, ttl, provider)
|
||||
Thread.new do
|
||||
begin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue