Sha256: 9413ec70fad8b1c0d84c1bc8f6add7c81205a54963d910609b54b33f67a8c82f
Contents?: true
Size: 1.29 KB
Versions: 53
Compression:
Stored size: 1.29 KB
Contents
require_relative 'common' require 'kontena/cli/helpers/health_helper' module Kontena::Cli::Etcd class HealthCommand < Kontena::Command include Kontena::Cli::Common include Kontena::Cli::GridOptions include Kontena::Cli::Helpers::HealthHelper parameter "[NODE]", "Show health for specific node" requires_current_master requires_current_grid 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 # @param id [String] :grid/:node # @return [Boolean] 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 end end
Version data entries
53 entries across 53 versions & 2 rubygems