Skip to content

Commit

Permalink
Merge pull request #371 from Shopify/runner-error-swallowed
Browse files Browse the repository at this point in the history
"Pod spec does not contain a template container called 'task-runner'" error message swallowed
  • Loading branch information
dturn committed Oct 30, 2018
2 parents 903e984 + bdb2398 commit c92bcfd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/kubernetes-deploy/runner_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ def build_pod_definition(base_template)
def set_container_overrides!(pod_definition, entrypoint, args, env_vars)
container = pod_definition.spec.containers.find { |cont| cont.name == 'task-runner' }
if container.nil?
raise TaskConfigurationError, "Pod spec does not contain a template container called 'task-runner'"
message = "Pod spec does not contain a template container called 'task-runner'"
@logger.summary.add_paragraph(message)
raise TaskConfigurationError, message
end

container.command = entrypoint
Expand Down
20 changes: 20 additions & 0 deletions test/integration/runner_task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,26 @@ def test_run_with_template_missing
end
end

def test_run_with_pod_spec_template_missing
deploy_task_template do |fixtures|
template = fixtures["template-runner.yml"]["PodTemplate"].first["template"]
template["spec"]["containers"].first["name"] = "bad-name"
end

task_runner = build_task_runner
assert_task_run_failure(task_runner.run(run_params))
message = "Pod spec does not contain a template container called 'task-runner'"

assert_raises_message(KubernetesDeploy::RunnerTask::TaskConfigurationError, message) do
task_runner.run!(run_params)
end

assert_logs_match_all([
"Result: FAILURE",
message
], in_order: true)
end

def test_run_adds_env_vars_provided_to_the_task_container
deploy_task_template

Expand Down

0 comments on commit c92bcfd

Please sign in to comment.