mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Fix RuboCop style violations
This commit is contained in:
parent
a83916a0a4
commit
6d6e998bf4
1 changed files with 133 additions and 106 deletions
|
|
@ -382,7 +382,7 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
def dlq_max_entries
|
def dlq_max_entries
|
||||||
($config[:config] && $config[:config]['dlq_max_entries']) || 10000
|
($config[:config] && $config[:config]['dlq_max_entries']) || 10_000
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_to_dlq(vm, pool, queue_type, error_class, error_message, redis, request_id: nil, pool_alias: nil, retry_count: 0, skip_metrics: false)
|
def move_to_dlq(vm, pool, queue_type, error_class, error_message, redis, request_id: nil, pool_alias: nil, retry_count: 0, skip_metrics: false)
|
||||||
|
|
@ -676,7 +676,7 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
def max_ready_age
|
def max_ready_age
|
||||||
($config[:config] && $config[:config]['max_ready_age']) || 86400 # default 24 hours in seconds
|
($config[:config] && $config[:config]['max_ready_age']) || 86_400 # default 24 hours in seconds
|
||||||
end
|
end
|
||||||
|
|
||||||
def max_completed_age
|
def max_completed_age
|
||||||
|
|
@ -684,7 +684,7 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
def max_orphaned_age
|
def max_orphaned_age
|
||||||
($config[:config] && $config[:config]['max_orphaned_age']) || 86400 # default 24 hours in seconds
|
($config[:config] && $config[:config]['max_orphaned_age']) || 86_400 # default 24 hours in seconds
|
||||||
end
|
end
|
||||||
|
|
||||||
def purge_stale_queue_entries
|
def purge_stale_queue_entries
|
||||||
|
|
@ -880,7 +880,7 @@ module Vmpooler
|
||||||
expiration_ttl = 3600 # 1 hour
|
expiration_ttl = 3600 # 1 hour
|
||||||
redis.expire(vm_key, expiration_ttl)
|
redis.expire(vm_key, expiration_ttl)
|
||||||
$logger.log('d', "[!] [purge] Set expiration on orphaned metadata for '#{vm}' (age: #{age.round(0)}s)")
|
$logger.log('d', "[!] [purge] Set expiration on orphaned metadata for '#{vm}' (age: #{age.round(0)}s)")
|
||||||
$metrics.increment("purge.orphaned.count")
|
$metrics.increment('purge.orphaned.count')
|
||||||
end
|
end
|
||||||
purged_count += 1
|
purged_count += 1
|
||||||
end
|
end
|
||||||
|
|
@ -904,7 +904,7 @@ module Vmpooler
|
||||||
'ready_queue_max' => 500,
|
'ready_queue_max' => 500,
|
||||||
'dlq_max_warning' => 100,
|
'dlq_max_warning' => 100,
|
||||||
'dlq_max_critical' => 1000,
|
'dlq_max_critical' => 1000,
|
||||||
'stuck_vm_age_threshold' => 7200, # 2 hours
|
'stuck_vm_age_threshold' => 7200, # 2 hours
|
||||||
'stuck_vm_max_warning' => 10,
|
'stuck_vm_max_warning' => 10,
|
||||||
'stuck_vm_max_critical' => 50
|
'stuck_vm_max_critical' => 50
|
||||||
}
|
}
|
||||||
|
|
@ -1055,11 +1055,11 @@ module Vmpooler
|
||||||
next unless pool_name
|
next unless pool_name
|
||||||
|
|
||||||
in_any_queue = redis.sismember("vmpooler__pending__#{pool_name}", vm) ||
|
in_any_queue = redis.sismember("vmpooler__pending__#{pool_name}", vm) ||
|
||||||
redis.sismember("vmpooler__ready__#{pool_name}", vm) ||
|
redis.sismember("vmpooler__ready__#{pool_name}", vm) ||
|
||||||
redis.sismember("vmpooler__running__#{pool_name}", vm) ||
|
redis.sismember("vmpooler__running__#{pool_name}", vm) ||
|
||||||
redis.sismember("vmpooler__completed__#{pool_name}", vm) ||
|
redis.sismember("vmpooler__completed__#{pool_name}", vm) ||
|
||||||
redis.sismember("vmpooler__discovered__#{pool_name}", vm) ||
|
redis.sismember("vmpooler__discovered__#{pool_name}", vm) ||
|
||||||
redis.sismember("vmpooler__migrating__#{pool_name}", vm)
|
redis.sismember("vmpooler__migrating__#{pool_name}", vm)
|
||||||
|
|
||||||
orphaned_count += 1 unless in_any_queue
|
orphaned_count += 1 unless in_any_queue
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
|
|
@ -1085,8 +1085,16 @@ module Vmpooler
|
||||||
metrics['queues'].each do |pool_name, queues|
|
metrics['queues'].each do |pool_name, queues|
|
||||||
next if pool_name == 'dlq'
|
next if pool_name == 'dlq'
|
||||||
|
|
||||||
pending_size = queues['pending']['size'] rescue 0
|
pending_size = begin
|
||||||
ready_size = queues['ready']['size'] rescue 0
|
queues['pending']['size']
|
||||||
|
rescue StandardError
|
||||||
|
0
|
||||||
|
end
|
||||||
|
ready_size = begin
|
||||||
|
queues['ready']['size']
|
||||||
|
rescue StandardError
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
return 'unhealthy' if pending_size > thresholds['pending_queue_max'] * 2
|
return 'unhealthy' if pending_size > thresholds['pending_queue_max'] * 2
|
||||||
return 'unhealthy' if ready_size > thresholds['ready_queue_max'] * 2
|
return 'unhealthy' if ready_size > thresholds['ready_queue_max'] * 2
|
||||||
|
|
@ -1099,8 +1107,16 @@ module Vmpooler
|
||||||
metrics['queues'].each do |pool_name, queues|
|
metrics['queues'].each do |pool_name, queues|
|
||||||
next if pool_name == 'dlq'
|
next if pool_name == 'dlq'
|
||||||
|
|
||||||
pending_size = queues['pending']['size'] rescue 0
|
pending_size = begin
|
||||||
ready_size = queues['ready']['size'] rescue 0
|
queues['pending']['size']
|
||||||
|
rescue StandardError
|
||||||
|
0
|
||||||
|
end
|
||||||
|
ready_size = begin
|
||||||
|
queues['ready']['size']
|
||||||
|
rescue StandardError
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
return 'degraded' if pending_size > thresholds['pending_queue_max']
|
return 'degraded' if pending_size > thresholds['pending_queue_max']
|
||||||
return 'degraded' if ready_size > thresholds['ready_queue_max']
|
return 'degraded' if ready_size > thresholds['ready_queue_max']
|
||||||
|
|
@ -1119,9 +1135,22 @@ module Vmpooler
|
||||||
|
|
||||||
metrics['queues'].each do |pool_name, queues|
|
metrics['queues'].each do |pool_name, queues|
|
||||||
next if pool_name == 'dlq'
|
next if pool_name == 'dlq'
|
||||||
total_pending += queues['pending']['size'] rescue 0
|
|
||||||
total_ready += queues['ready']['size'] rescue 0
|
total_pending += begin
|
||||||
total_completed += queues['completed']['size'] rescue 0
|
queues['pending']['size']
|
||||||
|
rescue StandardError
|
||||||
|
0
|
||||||
|
end
|
||||||
|
total_ready += begin
|
||||||
|
queues['ready']['size']
|
||||||
|
rescue StandardError
|
||||||
|
0
|
||||||
|
end
|
||||||
|
total_completed += begin
|
||||||
|
queues['completed']['size']
|
||||||
|
rescue StandardError
|
||||||
|
0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
summary += " | Queues: P=#{total_pending} R=#{total_ready} C=#{total_completed}"
|
summary += " | Queues: P=#{total_pending} R=#{total_ready} C=#{total_completed}"
|
||||||
|
|
@ -1154,10 +1183,8 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
# Push DLQ metrics
|
# Push DLQ metrics
|
||||||
if metrics['queues']['dlq']
|
metrics['queues']['dlq']&.each do |queue_type, dlq_metrics|
|
||||||
metrics['queues']['dlq'].each do |queue_type, dlq_metrics|
|
$metrics.gauge("health.dlq.#{queue_type}.size", dlq_metrics['size'])
|
||||||
$metrics.gauge("health.dlq.#{queue_type}.size", dlq_metrics['size'])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Push task metrics
|
# Push task metrics
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue