Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#417] fix error when installation returns a hostname instead of an i… #418

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading