Correctly handle multiple pools of same alias in ondemand checkout

This commit updates the method used for chceking the status of an
ondemand request to ensure that if multiple aliases are used to fulfill
a request that they are correctly presented as a single pool again when
everything is ready. Without this change it is possible for only one
group of an aliased pool to show up in pending or completed requests.
This commit is contained in:
kirby@puppetlabs.com 2020-07-07 14:19:28 -07:00
parent 6d01079f4a
commit 88899d4513

View file

@ -986,8 +986,13 @@ module Vmpooler
result['ready'] = true
Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, _count|
instances = backend.smembers("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
if result.key?(platform_alias)
result[platform_alias][:hostname] = result[platform_alias][:hostname] + instances
else
result[platform_alias] = { 'hostname': instances }
end
end
result['domain'] = config['domain'] if config['domain']
status 200
elsif request_hash['status'] == 'failed'
@ -999,12 +1004,19 @@ module Vmpooler
else
Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, count|
instance_count = backend.scard("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
instances_pending = count.to_i - instance_count.to_i
if result.key?(platform_alias) && result[platform_alias].key?(:ready)
result[platform_alias][:ready] = (result[platform_alias][:ready].to_i + instance_count).to_s
result[platform_alias][:pending] = (result[platform_alias][:pending].to_i + instances_pending).to_s
else
result[platform_alias] = {
'ready': instance_count.to_s,
'pending': (count.to_i - instance_count.to_i).to_s
'pending': instances_pending.to_s
}
end
end
end
result
end