class Krane::PodSetBase
Public Instance Methods
failure_message()
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 6 def failure_message pods.map(&:failure_message).compact.uniq.join("\n") end
fetch_debug_logs()
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 21 def fetch_debug_logs logs = Krane::RemoteLogs.new( logger: @logger, parent_id: id, container_names: container_names, namespace: @namespace, context: @context ) logs.sync logs end
fetch_events(kubectl)
click to toggle source
Calls superclass method
Krane::KubernetesResource#fetch_events
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 14 def fetch_events(kubectl) own_events = super return own_events unless pods.present? most_useful_pod = pods.find(&:deploy_failed?) || pods.find(&:deploy_timed_out?) || pods.first own_events.merge(most_useful_pod.fetch_events(kubectl)) end
print_debug_logs?()
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 33 def print_debug_logs? pods.present? # the kubectl command times out if no pods exist end
timeout_message()
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 10 def timeout_message pods.map(&:timeout_message).compact.uniq.join("\n") end
Private Instance Methods
container_names()
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 47 def container_names regular_containers = @definition["spec"]["template"]["spec"]["containers"].map { |c| c["name"] } init_containers = @definition["spec"]["template"]["spec"].fetch("initContainers", {}).map { |c| c["name"] } regular_containers + init_containers end
find_pods(cache)
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 53 def find_pods(cache) all_pods = cache.get_all(Pod.kind, @instance_data["spec"]["selector"]["matchLabels"]) all_pods.each_with_object([]) do |pod_data, relevant_pods| next unless parent_of_pod?(pod_data) pod = Pod.new( namespace: namespace, context: context, definition: pod_data, logger: @logger, parent: "#{name.capitalize} #{type}", deploy_started_at: @deploy_started_at ) pod.sync(cache) relevant_pods << pod end end
parent_of_pod?(_)
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 43 def parent_of_pod?(_) raise NotImplementedError, "Subclasses must define a `parent_of_pod?` method" end
pods()
click to toggle source
# File lib/krane/kubernetes_resource/pod_set_base.rb, line 39 def pods raise NotImplementedError, "Subclasses must define a `pods` accessor" end