diff --git a/CHANGELOG.md b/CHANGELOG.md index df48454..5140ca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ git logs & PR history. # [Unreleased](https://github.com/puppetlabs/vmpooler/compare/0.2.1...master) +### Fixed +- Return label used to request VMs when fulfilling VM requests (POOLER-131) + # [0.2.1](https://github.com/puppetlabs/vmpooler/compare/0.2.0...0.2.1) ### Fixed diff --git a/lib/vmpooler/api/v1.rb b/lib/vmpooler/api/v1.rb index 434e17e..640a8f9 100644 --- a/lib/vmpooler/api/v1.rb +++ b/lib/vmpooler/api/v1.rb @@ -67,9 +67,9 @@ module Vmpooler template_backends.each do |t| vm = backend.spop('vmpooler__ready__' + t) - return [vm, t] if vm + return [vm, t, template] if vm end - [nil, nil] + [nil, nil, nil] end def return_vm_to_ready_state(template, vm) @@ -113,27 +113,27 @@ module Vmpooler payload.each do |requested, count| count.to_i.times do |_i| - vm, name = fetch_single_vm(requested) - if !vm + vmname, vmpool, vmtemplate = fetch_single_vm(requested) + if !vmname failed = true metrics.increment('checkout.empty.' + requested) break else - vms << [ name, vm ] - metrics.increment('checkout.success.' + name) + vms << [ vmpool, vmname, vmtemplate ] + metrics.increment('checkout.success.' + vmtemplate) end end end if failed - vms.each do |(name, vm)| - return_vm_to_ready_state(name, vm) + vms.each do |(vmpool, vmname, vmtemplate)| + return_vm_to_ready_state(vmpool, vmname) end status 503 else - vms.each do |(name, vm)| - account_for_starting_vm(name, vm) - update_result_hosts(result, name, vm) + vms.each do |(vmpool, vmname, vmtemplate)| + account_for_starting_vm(vmpool, vmname) + update_result_hosts(result, vmtemplate, vmname) end result['ok'] = true diff --git a/spec/integration/api/v1/vm_spec.rb b/spec/integration/api/v1/vm_spec.rb index 5399370..4615949 100644 --- a/spec/integration/api/v1/vm_spec.rb +++ b/spec/integration/api/v1/vm_spec.rb @@ -82,7 +82,7 @@ describe Vmpooler::API::V1 do expected = { ok: true, - pool1: { + poolone: { hostname: 'abcdefghijklmnop' } } diff --git a/spec/integration/api/v1/vm_template_spec.rb b/spec/integration/api/v1/vm_template_spec.rb index 72fef36..0f71395 100644 --- a/spec/integration/api/v1/vm_template_spec.rb +++ b/spec/integration/api/v1/vm_template_spec.rb @@ -63,7 +63,7 @@ describe Vmpooler::API::V1 do expected = { ok: true, - pool1: { + poolone: { hostname: 'abcdefghijklmnop' } }