Class: KubernetesDeploy::PodSetBase

Inherits:
KubernetesResource show all
Defined in:
lib/kubernetes-deploy/kubernetes_resource/pod_set_base.rb

Direct Known Subclasses

DaemonSet, ReplicaSet, StatefulSet

Constant Summary

Constants inherited from KubernetesResource

KubernetesResource::DEBUG_RESOURCE_NOT_FOUND_MESSAGE, KubernetesResource::DISABLED_EVENT_INFO_MESSAGE, KubernetesResource::DISABLED_LOG_INFO_MESSAGE, KubernetesResource::DISABLE_FETCHING_EVENT_INFO, KubernetesResource::DISABLE_FETCHING_LOG_INFO, KubernetesResource::LOG_LINE_COUNT, KubernetesResource::STANDARD_TIMEOUT_MESSAGE, KubernetesResource::TIMEOUT, KubernetesResource::TIMEOUT_OVERRIDE_ANNOTATION, KubernetesResource::UNUSUAL_FAILURE_MESSAGE

Instance Attribute Summary

Attributes inherited from KubernetesResource

#context, #deploy_started_at, #name, #namespace, #type

Instance Method Summary collapse

Methods inherited from KubernetesResource

build, #debug_message, #deploy_failed?, #deploy_method, #deploy_started?, #deploy_succeeded?, #deploy_timed_out?, #exists?, #file_path, #id, #initialize, kind, #pretty_status, #pretty_timeout_type, #report_status_to_statsd, #status, #sync, #sync_debug_info, #timeout, timeout, #timeout_override, #validate_definition, #validation_error_msg, #validation_failed?

Constructor Details

This class inherits a constructor from KubernetesDeploy::KubernetesResource

Instance Method Details

#failure_messageObject



4
5
6
# File 'lib/kubernetes-deploy/kubernetes_resource/pod_set_base.rb', line 4

def failure_message
  pods.map(&:failure_message).compact.uniq.join("\n")
end

#fetch_events(kubectl) ⇒ Object



12
13
14
15
16
17
# File 'lib/kubernetes-deploy/kubernetes_resource/pod_set_base.rb', line 12

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

#fetch_logs(kubectl) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kubernetes-deploy/kubernetes_resource/pod_set_base.rb', line 19

def fetch_logs(kubectl)
  return {} unless pods.present? # the kubectl command times out if no pods exist
  container_names.each_with_object({}) do |container_name, container_logs|
    out, _err, _st = kubectl.run(
      "logs",
      id,
      "--container=#{container_name}",
      "--since-time=#{@deploy_started_at.to_datetime.rfc3339}",
      "--tail=#{LOG_LINE_COUNT}",
      log_failure: false
    )
    container_logs[container_name] = out.split("\n")
  end
end

#timeout_messageObject



8
9
10
# File 'lib/kubernetes-deploy/kubernetes_resource/pod_set_base.rb', line 8

def timeout_message
  pods.map(&:timeout_message).compact.uniq.join("\n")
end