From 1d48e805b5a68bcb3a82d57f6c5f4072d5a9d8db Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 13 Jun 2023 11:12:06 -0400 Subject: [PATCH] Improve performance of capture_ems_targets For Kubernetes type providers if the ems has metrics credentials then all instances of container_nodes, container_groups, etc... supports capture. We don't have to check `.supporting(:capture)` if we are in a kubernetes provider, but this isn't generally true so only implement this behavior in k8s. --- .../kubernetes/container_manager/metrics_capture.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture.rb b/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture.rb index 7069c176c8..e1cec0b642 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture.rb @@ -57,7 +57,12 @@ def capture_ems_targets(_options = {}) return [] end - super + MiqPreloader.preload([ems], :container_images => :tags, :container_nodes => :tags, :container_groups => [:tags, :containers => :tags]) + + with_archived(ems.all_container_nodes) + + with_archived(ems.all_container_groups) + + with_archived(ems.all_containers) + + with_archived(ems.container_images) end def prometheus_capture_context(target, start_time, end_time)