From 8beab7f874a6a7857c2f2260a52cf881684b97c2 Mon Sep 17 00:00:00 2001 From: isaac-hammes Date: Wed, 23 Aug 2023 08:41:07 -0700 Subject: [PATCH 1/3] (maint) Fix bug where fail_pending_vm was logging an error before any timeouts are reached. --- lib/vmpooler/pool_manager.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index 82ed6a55..128ad605 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -129,6 +129,8 @@ def fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: true already_timed_out = time_since_clone > timeout timing_out_soon = time_since_clone > timeout_notification && !redis.hget("vmpooler__vm__#{vm}", 'timeout_notification') + return true if !already_timed_out && !timing_out_soon + if already_timed_out unless exists remove_nonexistent_vm(vm, pool, redis) From 1c5b066c942da33bc73f83ca359529e83255a91f Mon Sep 17 00:00:00 2001 From: isaac-hammes Date: Wed, 23 Aug 2023 12:03:26 -0700 Subject: [PATCH 2/3] (maint) Fix bug by removing redis transaction --- lib/vmpooler/api/v3.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/vmpooler/api/v3.rb b/lib/vmpooler/api/v3.rb index 41c64804..30b5b7c5 100644 --- a/lib/vmpooler/api/v3.rb +++ b/lib/vmpooler/api/v3.rb @@ -283,11 +283,9 @@ def component_to_test(match, labels_string) def update_user_metrics(operation, vmname) tracer.in_span("Vmpooler::API::V3.#{__method__}") do |span| begin - backend.multi - backend.hget("vmpooler__vm__#{vmname}", 'tag:jenkins_build_url') - backend.hget("vmpooler__vm__#{vmname}", 'token:user') - backend.hget("vmpooler__vm__#{vmname}", 'template') - jenkins_build_url, user, poolname = backend.exec + jenkins_build_url = backend.hget("vmpooler__vm__#{vmname}", 'tag:jenkins_build_url') + user = backend.hget("vmpooler__vm__#{vmname}", 'token:user') + poolname = backend.hget("vmpooler__vm__#{vmname}", 'template') poolname = poolname.gsub('.', '_') if user From ef7000dafc29cace513af647e646b98803da65c9 Mon Sep 17 00:00:00 2001 From: isaac-hammes Date: Thu, 24 Aug 2023 06:24:13 -0700 Subject: [PATCH 3/3] (maint) Fix spec test to catch unexpected logging in fail_pending_vm. --- spec/unit/pool_manager_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/unit/pool_manager_spec.rb b/spec/unit/pool_manager_spec.rb index a9c8307e..3ca075e2 100644 --- a/spec/unit/pool_manager_spec.rb +++ b/spec/unit/pool_manager_spec.rb @@ -275,6 +275,7 @@ it 'takes no action if VM is not cloning' do redis_connection_pool.with do |redis| + expect(logger).to_not receive(:log) expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis)).to eq(true) end end @@ -282,6 +283,7 @@ it 'takes no action if VM is within timeout' do redis_connection_pool.with do |redis| redis.hset("vmpooler__vm__#{vm}", 'clone',Time.now.to_s) + expect(logger).to_not receive(:log) expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis)).to eq(true) expect(redis.sismember("vmpooler__pending__#{pool}", vm)).to be(true) end @@ -307,6 +309,7 @@ it 'calls remove_nonexistent_vm if VM has exceeded timeout and does not exist' do redis_connection_pool.with do |redis| redis.hset("vmpooler__vm__#{vm}", 'clone',Date.new(2001,1,1).to_s) + expect(logger).to_not receive(:log) expect(subject).to receive(:remove_nonexistent_vm).with(vm, pool, redis) expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: false)).to eq(true) end