ashb commented on code in PR #46860:
URL: https://github.com/apache/airflow/pull/46860#discussion_r1962129709
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/pod_generator.py:
##########
@@ -341,18 +350,48 @@ def construct_pod(
run_id=run_id,
),
),
- spec=k8s.V1PodSpec(
- containers=[
- k8s.V1Container(
- name="base",
- args=args,
- image=image,
- env=[k8s.V1EnvVar(name="AIRFLOW_IS_K8S_EXECUTOR_POD",
value="True")],
- )
- ]
- ),
)
+ podspec = k8s.V1PodSpec(
+ containers=[main_container],
+ )
+
+ if content_json_for_volume:
+ import shlex
+
+ input_file_path = "/tmp/execute/input.json"
+ execute_volume = V1Volume(
+ name="execute-volume",
+ empty_dir=V1EmptyDirVolumeSource(),
+ )
+
+ execute_volume_mount = V1VolumeMount(
+ name="execute-volume",
+ mount_path="/tmp/execute",
+ read_only=False,
+ )
+
+ escaped_json = shlex.quote(content_json_for_volume)
+ init_container = k8s.V1Container(
+ name="init-container",
+ image="busybox",
+ command=["/bin/sh", "-c", f"echo {escaped_json} >
{input_file_path}"],
+ volume_mounts=[execute_volume_mount],
+ )
+
+ main_container.volume_mounts = [execute_volume_mount]
+ main_container.env.append(k8s.V1EnvVar(name="EXECUTE_JSON",
value=content_json_for_volume))
Review Comment:
Nit: Maybe call this variable `WORKLOAD_JSON_PATH` or something? (The
`_PATH` the main part, so `EXECUTE_JSON_PATH` okay too) to make it clear this
is a path to the json file, not the json directly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]