Class: KubernetesDeploy::DaemonSet
- Inherits:
-
PodSetBase
- Object
- KubernetesResource
- PodSetBase
- KubernetesDeploy::DaemonSet
- Defined in:
- lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb
Constant Summary collapse
- TIMEOUT =
5.minutes
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_OVERRIDE_ANNOTATION, KubernetesResource::UNUSUAL_FAILURE_MESSAGE
Instance Attribute Summary collapse
-
#pods ⇒ Object
readonly
Returns the value of attribute pods.
Attributes inherited from KubernetesResource
#context, #deploy_started_at, #name, #namespace, #type
Instance Method Summary collapse
- #deploy_failed? ⇒ Boolean
- #deploy_succeeded? ⇒ Boolean
- #exists? ⇒ Boolean
- #fetch_logs ⇒ Object
- #sync ⇒ Object
Methods inherited from PodSetBase
#failure_message, #fetch_events, #timeout_message
Methods inherited from KubernetesResource
build, #debug_message, #deploy_method, #deploy_started?, #deploy_timed_out?, #failure_message, #fetch_events, #file_path, #id, #initialize, #kubectl, #pretty_status, #pretty_timeout_type, #report_status_to_statsd, #status, #sync_debug_info, timeout, #timeout, #timeout_message, #timeout_override, #validate_definition, #validation_error_msg, #validation_failed?
Constructor Details
This class inherits a constructor from KubernetesDeploy::KubernetesResource
Instance Attribute Details
#pods ⇒ Object (readonly)
Returns the value of attribute pods.
6 7 8 |
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 6 def pods @pods end |
Instance Method Details
#deploy_failed? ⇒ Boolean
35 36 37 |
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 35 def deploy_failed? pods.present? && pods.any?(&:deploy_failed?) end |
#deploy_succeeded? ⇒ Boolean
29 30 31 32 33 |
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 29 def deploy_succeeded? @rollout_data["desiredNumberScheduled"].to_i == @rollout_data["currentNumberScheduled"].to_i && @rollout_data["desiredNumberScheduled"].to_i == @rollout_data["numberReady"].to_i && @current_generation == @observed_generation end |
#exists? ⇒ Boolean
44 45 46 |
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 44 def exists? @found end |
#fetch_logs ⇒ Object
39 40 41 42 |
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 39 def fetch_logs most_useful_pod = @pods.find(&:deploy_failed?) || @pods.find(&:deploy_timed_out?) || @pods.first most_useful_pod.fetch_logs end |
#sync ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 8 def sync raw_json, _err, st = kubectl.run("get", type, @name, "--output=json") @found = st.success? if @found daemonset_data = JSON.parse(raw_json) @current_generation = daemonset_data["metadata"]["generation"] @observed_generation = daemonset_data["status"]["observedGeneration"] @rollout_data = daemonset_data["status"] .slice("currentNumberScheduled", "desiredNumberScheduled", "numberReady") @status = @rollout_data.map { |state_replicas, num| "#{num} #{state_replicas}" }.join(", ") @pods = find_pods(daemonset_data) else # reset @rollout_data = { "currentNumberScheduled" => 0 } @current_generation = 1 # to make sure the current and observed generations are different @observed_generation = 0 @status = nil @pods = [] end end |