class Kontena::Cli::Nodes::HealthCommand

Public Instance Methods

execute() click to toggle source
# File lib/kontena/cli/nodes/health_command.rb, line 16
def execute
  return show_node_health("#{current_grid}/#{self.node}")
end
show_node_health(id) click to toggle source

@param id [String] :grid/:node @return [Boolean] true if healthy

# File lib/kontena/cli/nodes/health_command.rb, line 22
def show_node_health(id)
  node_health = client.get("nodes/#{id}/health")

  if node_health['status'] == 'online'
    puts "#{health_icon(:ok)} Node is online for #{time_since(node_health['connected_at'])}"
  else
    puts "#{health_icon(:warning)} Node is #{node_health['status']}"
  end

  etcd_health, etcd_status = node_etcd_health(node_health['etcd_health'])

  puts "#{health_icon etcd_health} Node #{node_health['name']} etcd is #{etcd_status}"

  return etcd_health == :ok

rescue Kontena::Errors::StandardErrorHash => exc
  raise unless exc.status == 422

  exc.errors.each do |what, error|
    puts "#{health_icon :offline} Node #{id} #{what} error: #{error}"
  end

  return false
end