brandonwillard commented on a change in pull request #7405: [AIRFLOW-6780] Add
option to use args instead of command in K8s pod spec
URL: https://github.com/apache/airflow/pull/7405#discussion_r403589325
##########
File path: airflow/kubernetes/pod_generator.py
##########
@@ -397,24 +397,32 @@ def reconcile_containers(base_containers:
List[k8s.V1Container],
)
@staticmethod
- def construct_pod(
+ def construct_pod( # pylint: disable=too-many-arguments
dag_id: str,
task_id: str,
pod_id: str,
try_number: int,
date: str,
- command: List[str],
+ command: Optional[List[str]],
kube_executor_config: Optional[k8s.V1Pod],
worker_config: k8s.V1Pod,
namespace: str,
- worker_uuid: str
+ worker_uuid: str,
+ use_args: Optional[bool] = False,
) -> k8s.V1Pod:
"""
Construct a pod by gathering and consolidating the configuration from
3 places:
- airflow.cfg
- executor_config
- dynamic arguments
"""
+
+ if use_args:
+ args = command
+ command = []
+ else:
+ args = []
Review comment:
This functionality was only intended for the Executor, and, yeah, the
question about where to put it did come to mind (i.e. between `PodGenerator` or
`KubernetesExecutor`).
"Thematically" speaking, the option to choose the `args` or `command` field
seemed most appropriate for `PodGenerator.construct_pod`, i.e. a method
intended to generally construct pods, and one that already takes a `command`
argument. (Side note: I'm admittedly not a fan of the `use_args` "switch", but
I didn't want to change an interface used by others, so I opted to simply
augment/extend it.)
In general, I didn't want to add pod construction/manipulation logic to
`KubernetesExecutor.run_next`; it just didn't seem good to have that kind of
stuff spread around the code base.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services