lib/kubernetes-deploy/kubernetes_resource/pod.rb in kubernetes-deploy-0.2.2 vs lib/kubernetes-deploy/kubernetes_resource/pod.rb in kubernetes-deploy-0.2.3
- old
+ new
@@ -1,12 +1,12 @@
module KubernetesDeploy
class Pod < KubernetesResource
TIMEOUT = 15.minutes
SUSPICIOUS_CONTAINER_STATES = %w(ImagePullBackOff RunContainerError).freeze
- def initialize(name, namespace, file, parent: nil)
- @name, @namespace, @file, @parent = name, namespace, file, parent
+ def initialize(name, namespace, context, file, parent: nil)
+ @name, @namespace, @context, @file, @parent = name, namespace, context, file, parent
@bare = !@parent
end
def sync
out, st = run_kubectl("get", type, @name, "-a", "--output=json")
@@ -38,10 +38,10 @@
if @phase == "Failed"
@status = "#{@phase} (Reason: #{pod_data["status"]["reason"]})"
elsif @phase == "Terminating"
@status = @phase
else
- ready_condition = pod_data["status"]["conditions"].find { |condition| condition["type"] == "Ready" }
+ ready_condition = pod_data["status"].fetch("conditions", []).find { |condition| condition["type"] == "Ready" }
@ready = ready_condition.present? && (ready_condition["status"] == "True")
@status = "#{@phase} (Ready: #{@ready})"
end
end