From 18988ddc3c56de6ca2a470d627405629ff9fc05f Mon Sep 17 00:00:00 2001 From: John O'Connor Date: Fri, 21 Aug 2020 18:49:30 +0100 Subject: [PATCH] (MAINT) Fix Staledns error counter This was logging the hostname instead of the poolname. --- lib/vmpooler/pool_manager.rb | 2 +- spec/unit/pool_manager_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index 35b4226..95927d4 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -368,7 +368,7 @@ module Vmpooler $metrics.increment("errors.duplicatehostname.#{pool_name}") $logger.log('s', "[!] [#{pool_name}] Generated hostname #{hostname} was not unique (attempt \##{hostname_retries} of #{max_hostname_retries})") elsif !dns_available - $metrics.increment("errors.staledns.#{hostname}") + $metrics.increment("errors.staledns.#{pool_name}") $logger.log('s', "[!] [#{pool_name}] Generated hostname #{hostname} already exists in DNS records (#{dns_ip}), stale DNS") end end diff --git a/spec/unit/pool_manager_spec.rb b/spec/unit/pool_manager_spec.rb index 204a2d7..e8a17a1 100644 --- a/spec/unit/pool_manager_spec.rb +++ b/spec/unit/pool_manager_spec.rb @@ -913,7 +913,7 @@ EOT resolv = class_double("Resolv").as_stubbed_const(:transfer_nested_constants => true) expect(subject).to receive(:generate_and_check_hostname).exactly(3).times.and_return([vm_name, true]) #skip this, make it available all times expect(resolv).to receive(:getaddress).exactly(3).times.and_return("1.2.3.4") - expect(metrics).to receive(:increment).with("errors.staledns.#{vm_name}").exactly(3).times + expect(metrics).to receive(:increment).with("errors.staledns.#{pool}").exactly(3).times expect{subject._clone_vm(pool,provider)}.to raise_error(/Unable to generate a unique hostname after/) end it 'should be successful if DNS does not exist' do