Skip to content

Commit

Permalink
Merge pull request #317 from Shopify/improve-preemption-handling
Browse files Browse the repository at this point in the history
Don't consider pod preempting a failure
  • Loading branch information
DazWorrall committed Jul 17, 2018
2 parents 435b545 + ab83055 commit dc5fd47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/kubernetes-deploy/kubernetes_resource/pod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class Pod < KubernetesResource
TIMEOUT = 10.minutes

FAILED_PHASE_NAME = "Failed"
TRANSIENT_FAILURE_REASONS = %w(
Evicted
Preempting
)

def initialize(namespace:, context:, definition:, logger:,
statsd_tags: nil, parent: nil, deploy_started_at: nil)
Expand Down Expand Up @@ -57,7 +61,7 @@ def timeout_message
end

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

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 @@ -170,6 +170,21 @@ def test_deploy_failed_is_false_for_evicted
assert_nil pod.failure_message
end

def test_deploy_failed_is_false_for_preempting
container_state = pod_spec.merge(
"status" => {
"message" => "Preempted in order to admit critical pod",
"phase" => "Failed",
"reason" => "Preempting",
"startTime" => "2018-04-13T22:43:23Z"
}
)
pod = build_synced_pod(container_state)

refute_predicate pod, :deploy_failed?
assert_nil pod.failure_message
end

private

def pod_spec
Expand Down

0 comments on commit dc5fd47

Please sign in to comment.