Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent deploys from failing if pod is evicted #293

Merged
merged 2 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/kubernetes-deploy/kubernetes_resource/pod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def sync(mediator)
end

def status
return phase if @instance_data.dig('status', 'reason').blank?
"#{phase} (Reason: #{@instance_data['status']['reason']})"
return phase if reason.blank?
"#{phase} (Reason: #{reason})"
end

def deploy_succeeded?
Expand All @@ -57,7 +57,7 @@ def timeout_message
end

def failure_message
if phase == FAILED_PHASE_NAME
if phase == FAILED_PHASE_NAME && reason != "Evicted"
phase_problem = "Pod status: #{status}. "
end

Expand Down Expand Up @@ -102,6 +102,10 @@ def phase
@instance_data.dig("status", "phase") || "Unknown"
end

def reason
@instance_data.dig('status', 'reason')
end

def readiness_probe_failure?
return false if ready? || unmanaged?
return false if phase != "Running"
Expand Down
15 changes: 15 additions & 0 deletions test/unit/kubernetes-deploy/kubernetes_resource/pod_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ def test_deploy_failed_is_true_for_container_cannot_run_error
assert_equal expected_msg, pod.failure_message
end

def test_deploy_failed_is_false_for_evicted
container_state = pod_spec.merge(
"status" => {
"message" => "The node was low on resource: nodefsInodes.",
"phase" => "Failed",
"reason" => "Evicted",
"startTime" => "2018-04-13T22:43:23Z"
}
)
pod = build_synced_pod(container_state)

refute pod.deploy_failed?
assert_nil pod.failure_message
end

private

def pod_spec
Expand Down