-
Notifications
You must be signed in to change notification settings - Fork 70
/
not_paused.rb
31 lines (28 loc) · 1.05 KB
/
not_paused.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Checks::ForemanTasks
class NotPaused < ForemanMaintain::Check
include ForemanMaintain::Concerns::Hammer
metadata do
for_feature :foreman_tasks
description 'Check for paused tasks'
tags :default
after :services_up, :server_ping
end
def run
paused_tasks_count = feature(:foreman_tasks).paused_tasks_count(ignored_tasks)
assert(paused_tasks_count == 0,
"There are currently #{paused_tasks_count} paused tasks in the system",
:next_steps =>
[Procedures::ForemanTasks::Resume.new,
Procedures::ForemanTasks::UiInvestigate.new('search_query' => scoped_search_query)])
end
# Note: this is for UI link generation only: we are not using scoped search for querying
# the tasks itself as we use direct SQL instead
def scoped_search_query
"state = paused AND label !^(#{ignored_tasks.join(' ')})"
end
def ignored_tasks
%w[Actions::Candlepin::ListenOnCandlepinEvents
Actions::Katello::EventQueue::Monitor]
end
end
end