Skip to content

Commit

Permalink
fix issue with k8s_job_op when combining command and container_config (
Browse files Browse the repository at this point in the history
…#11713)

Summary:
You can't add a key to an immutable dict.

Test Plan: New test case

### Summary & Motivation

### How I Tested These Changes
  • Loading branch information
gibsondan committed Jan 14, 2023
1 parent 429c414 commit e9bb3ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,28 @@ def with_config_job():
job_name = get_k8s_job_name(run_id, with_container_config.name)

assert "SHELL_FROM_CONTAINER_CONFIG" in _get_pod_logs(cluster_provider, job_name, namespace)


@pytest.mark.default
def test_k8s_job_op_with_container_config_and_command(namespace, cluster_provider):
with_container_config = k8s_job_op.configured(
{
"image": "busybox",
"container_config": {"command": ["echo", "SHELL_FROM_CONTAINER_CONFIG"]},
"namespace": namespace,
"load_incluster_config": False,
"kubeconfig_file": cluster_provider.kubeconfig_file,
"command": ["echo", "OVERRIDES_CONTAINER_CONFIG"],
},
name="with_container_config",
)

@job
def with_config_job():
with_container_config()

execute_result = with_config_job.execute_in_process()
run_id = execute_result.dagster_run.run_id
job_name = get_k8s_job_name(run_id, with_container_config.name)

assert "OVERRIDES_CONTAINER_CONFIG" in _get_pod_logs(cluster_provider, job_name, namespace)
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def execute_k8s_job(
else None,
)

container_config = container_config or {}
container_config = container_config.copy() if container_config else {}
if command:
container_config["command"] = command

Expand Down

0 comments on commit e9bb3ee

Please sign in to comment.