From 3d26da22c4ddb6d5470e15a553f31283042ea460 Mon Sep 17 00:00:00 2001 From: Mooli Tayer Date: Thu, 27 Apr 2017 17:26:01 +0300 Subject: [PATCH] Avoid metrics collection workers unless endpoint --- .../container_manager/metrics_collector_worker.rb | 9 +++++++++ .../providers/kubernetes/container_manager_mixin.rb | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/app/models/manageiq/providers/kubernetes/container_manager/metrics_collector_worker.rb b/app/models/manageiq/providers/kubernetes/container_manager/metrics_collector_worker.rb index f947878ca6..6ce7a87111 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/metrics_collector_worker.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/metrics_collector_worker.rb @@ -11,5 +11,14 @@ def friendly_name def self.ems_class ManageIQ::Providers::Kubernetes::ContainerManager end + + # Override PerEmsTypeWorkerMixin.emses_in_zone to limit metrics collection + def self.emses_in_zone + super.select do |ems| + ems.supports_metrics?.tap do |supported| + _log.info("Skipping [#{ems.name}] since it has no metrics endpoint") unless supported + end + end + end end end diff --git a/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb b/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb index ce4f0848e5..280ee39f06 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb @@ -14,6 +14,10 @@ module ManageIQ::Providers::Kubernetes::ContainerManagerMixin end end + def supports_metrics? + connection_configurations.hawkular != nil + end + module ClassMethods def raw_api_endpoint(hostname, port, path = '') URI::HTTPS.build(:host => hostname, :port => port.presence.try(:to_i), :path => path)