Skip to content

Commit

Permalink
[#417] fix error when installation returns a hostname instead of an i…
Browse files Browse the repository at this point in the history
…p address
  • Loading branch information
lidiamokevnina committed Jun 24, 2024
1 parent d6562bd commit 8d78724
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/uffizzi/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -94,7 +94,7 @@ def wait_ip

spinner.success

ip
endpoint
end

def build_helm_values(params)
Expand Down Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions lib/uffizzi/services/install_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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)
Expand Down

0 comments on commit 8d78724

Please sign in to comment.