From fb18d4bbeb29ad6a17d5b655eca4dab715724db4 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 5 Mar 2024 14:33:27 -0500 Subject: [PATCH] Fix prometheus http_proxy using 0.0.0.0:80 When `VMDB::Util.http_proxy_uri` is `nil` `VMDB::Util.http_proxy_uri.to_s` is `""`. With uri v0.10.3 `URI.parse("http://")` would have a `host` of `nil` but on v0.13.0 `URI.parse("http://")` has a `host` of `""`. This was causing Faraday to use a proxy of `0.0.0.0:80` instead of none. --- app/models/manageiq/providers/kubernetes/container_manager.rb | 3 ++- .../metrics_capture/prometheus_client_mixin.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/manageiq/providers/kubernetes/container_manager.rb b/app/models/manageiq/providers/kubernetes/container_manager.rb index b5a2d31d9b..500ef41047 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager.rb @@ -662,8 +662,9 @@ def self.prometheus_connect(hostname, port, options) credentials = {:token => options[:bearer]} ssl_options = options[:ssl_options] || {:verify_ssl => OpenSSL::SSL::VERIFY_NONE} + http_proxy_uri = options[:http_proxy] || VMDB::Util.http_proxy_uri.to_s prometheus_options = { - :http_proxy_uri => options[:http_proxy] || VMDB::Util.http_proxy_uri.to_s, + :http_proxy_uri => http_proxy_uri.presence, :verify_ssl => ssl_options[:verify_ssl], :ssl_cert_store => ssl_options[:ca_file], } diff --git a/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture/prometheus_client_mixin.rb b/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture/prometheus_client_mixin.rb index 76989becab..249f5c27de 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture/prometheus_client_mixin.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture/prometheus_client_mixin.rb @@ -36,7 +36,7 @@ def prometheus_options worker_class = ManageIQ::Providers::Kubernetes::ContainerManager::MetricsCollectorWorker { - :http_proxy_uri => VMDB::Util.http_proxy_uri.to_s, + :http_proxy_uri => VMDB::Util.http_proxy_uri.to_s.presence, :verify_ssl => @ext_management_system.verify_ssl_mode(prometheus_endpoint), :ssl_cert_store => @ext_management_system.ssl_cert_store(prometheus_endpoint), :open_timeout => worker_class.worker_settings[:prometheus_open_timeout] || 5,