Class: Krane::PodSetBase

Inherits:
KubernetesResource show all
Defined in:
lib/krane/kubernetes_resource/pod_set_base.rb

Direct Known Subclasses

DaemonSet, ReplicaSet, StatefulSet

Constant Summary

Constants inherited from KubernetesResource

KubernetesResource::ALLOWED_DEPLOY_METHOD_OVERRIDES, KubernetesResource::DEBUG_RESOURCE_NOT_FOUND_MESSAGE, KubernetesResource::DEPLOY_METHOD_OVERRIDE_ANNOTATION, KubernetesResource::DISABLED_EVENT_INFO_MESSAGE, KubernetesResource::DISABLED_LOG_INFO_MESSAGE, KubernetesResource::DISABLE_FETCHING_EVENT_INFO, KubernetesResource::DISABLE_FETCHING_LOG_INFO, KubernetesResource::GLOBAL, KubernetesResource::LAST_APPLIED_ANNOTATION, KubernetesResource::LOG_LINE_COUNT, KubernetesResource::SENSITIVE_TEMPLATE_CONTENT, KubernetesResource::SERVER_DRY_RUNNABLE, KubernetesResource::SERVER_DRY_RUN_DISABLED_ERROR, KubernetesResource::STANDARD_TIMEOUT_MESSAGE, KubernetesResource::SYNC_DEPENDENCIES, KubernetesResource::TIMEOUT, KubernetesResource::TIMEOUT_OVERRIDE_ANNOTATION, KubernetesResource::UNUSUAL_FAILURE_MESSAGE

Instance Attribute Summary

Attributes inherited from KubernetesResource

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

Instance Method Summary collapse

Methods inherited from KubernetesResource

#<=>, #after_sync, build, class_for_kind, #current_generation, #debug_message, #deploy_failed?, #deploy_method, #deploy_method_override, #deploy_started?, #deploy_succeeded?, #deploy_timed_out?, #disappeared?, #exists?, #file_path, #global?, #group, #id, #initialize, kind, #kubectl_resource_type, #observed_generation, #pretty_status, #pretty_timeout_type, #report_status_to_statsd, #selected?, #sensitive_template_content?, #server_dry_run_validated?, #server_dry_runnable_resource?, #status, #sync, #sync_debug_info, #terminating?, timeout, #timeout, #timeout_override, #to_kubeclient_resource, #use_generated_name, #uses_generate_name?, #validate_definition, #validation_error_msg, #validation_failed?, #version

Constructor Details

This class inherits a constructor from Krane::KubernetesResource

Instance Method Details

#failure_messageObject



6
7
8
# 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_logsObject



21
22
23
24
25
26
27
28
29
30
31
# 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) ⇒ Object



14
15
16
17
18
19
# 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

Returns:

  • (Boolean)


33
34
35
# 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_messageObject



10
11
12
# File 'lib/krane/kubernetes_resource/pod_set_base.rb', line 10

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