Skip to content

Commit 39b5ead

Browse files
committed
Adds role check before queuing the job;
Also removes the check for server zone
1 parent abc7726 commit 39b5ead

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/controllers/mixins/ems_common/metrics.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ def refresh_or_capture_emss(task, action_name)
7272
if task == "refresh_ems"
7373
model.refresh_ems(emss, true)
7474
elsif task == "capture_ems"
75-
emss.each(&:queue_metrics_capture)
75+
emss.each do |ems|
76+
unless ems.zone.role_active?("ems_metrics_coordinator")
77+
add_flash(_("Capacity & Utilization Coordinator role is off for %{name}") % {:name => ems.name}, :error)
78+
else
79+
ems.queue_metrics_capture
80+
end
81+
end
7682
end
7783

7884
add_task_flash(emss, action_name)

app/helpers/application_helper/button/ems_capture_metrics.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ def disabled?
55
check_credentials
66
check_refresh
77
check_endpoint
8+
check_role
89
end
9-
check_role
10-
1110
@error_message.present?
1211
end
1312

@@ -26,7 +25,7 @@ def check_endpoint
2625
def check_role
2726
metrics_collection =
2827
ManageIQ::Providers::Kubernetes::ContainerManager.method_defined?(:queue_metrics_capture) &&
29-
(@record ? @record.zone.role_active?("ems_metrics_coordinator") : MiqServer.my_server.zone.role_active?("ems_metrics_coordinator"))
28+
@record.zone.role_active?("ems_metrics_coordinator")
3029

3130
@error_message ||= _("Capacity & Utilization Coordinator role is off") unless metrics_collection
3231
end

0 commit comments

Comments
 (0)