From 8d7872499e70f5cea06aa7a4f160e6a39d8b9da8 Mon Sep 17 00:00:00 2001 From: Lidia Mokevnina Date: Mon, 24 Jun 2024 17:16:47 +0200 Subject: [PATCH] [#417] fix error when installation returns a hostname instead of an ip address --- lib/uffizzi/cli/install.rb | 14 +++++++------- lib/uffizzi/services/install_service.rb | 7 +++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/uffizzi/cli/install.rb b/lib/uffizzi/cli/install.rb index 2024a5d0..011adfb6 100644 --- a/lib/uffizzi/cli/install.rb +++ b/lib/uffizzi/cli/install.rb @@ -71,16 +71,16 @@ def build_installation_options(uri) } end - def wait_ip + def wait_endpoint spinner = TTY::Spinner.new('[:spinner] Waiting on IP address...', format: :dots) spinner.auto_spin - ip = nil + endpoint = nil try = 0 loop do - ip = InstallService.get_controller_ip(namespace) - break if ip.present? + endpoint = InstallService.get_controller_endpoint(namespace) + break if endpoint.present? if try == 90 spinner.error @@ -94,7 +94,7 @@ def wait_ip spinner.success - ip + endpoint end def build_helm_values(params) @@ -196,10 +196,10 @@ def build_controller_setting_params(uri, installation_options) end def say_success(uri) - ip_address = wait_ip + endpoint = wait_endpoint msg = 'Your Uffizzi controller is ready. To configure DNS,'\ - " create a record for the hostname '*.#{uri.host}' pointing to '#{ip_address}'" + " create a record for the hostname '*.#{uri.host}' pointing to '#{endpoint}'" Uffizzi.ui.say(msg) end diff --git a/lib/uffizzi/services/install_service.rb b/lib/uffizzi/services/install_service.rb index eac73be7..9874afd9 100644 --- a/lib/uffizzi/services/install_service.rb +++ b/lib/uffizzi/services/install_service.rb @@ -85,7 +85,7 @@ def kubeconfig_current_context execute_command(cmd, say: false) { |stdout| stdout.present? && stdout.chop } end - def get_controller_ip(namespace) + def get_controller_endpoint(namespace) cmd = "kubectl get ingress -n #{namespace} -o json" res = execute_command(cmd, say: false) ingress = JSON.parse(res)['items'].detect { |i| i['metadata']['name'] = INGRESS_NAME } @@ -95,7 +95,10 @@ def get_controller_ip(namespace) load_balancers = ingress.dig('status', 'loadBalancer', 'ingress') return if load_balancers.blank? - load_balancers.map { |i| i['ip'] }[0] + ip = load_balancers.map { |i| i['ip'] }[0] + return ip if ip.present? + + load_balancers.map { |i| i['hostname'] }[0] end def build_controller_host(host)