class Kontena::Cli::Etcd::HealthCommand

Public Instance Methods

execute() click to toggle source
# File lib/kontena/cli/etcd/health_command.rb, line 15
def execute
  ret = true

  if self.node
    ret = show_etcd_health("#{current_grid}/#{self.node}")
  else
    nodes = client.get("grids/#{current_grid}/nodes")['nodes']

    nodes.each do |node|
      if !show_etcd_health(node['id'])
        ret = false
      end
    end
  end

  return ret
end
show_etcd_health(id) click to toggle source

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

# File lib/kontena/cli/etcd/health_command.rb, line 35
def show_etcd_health(id)
  node_health = client.get("nodes/#{id}/health")
  etcd_health, status = node_etcd_health(node_health['etcd_health'])

  puts "#{health_icon etcd_health} Node #{node_health['name']} etcd is #{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