vanchaxy commented on PR #24342:
URL: https://github.com/apache/airflow/pull/24342#issuecomment-1159719089

   > can you clarify your concern, perhaps with an example?
   
   @dstandish after this change the task like this will never work:
   ```
   @task(executor_config="pod_override": 
k8s.V1Pod(metadata=k8s.V1ObjectMeta(labels={"airflow-worker": "wrong-value"})))
   def start_task():
       print()
   ```
   
   It's now only about `airflow-worker`: specifying any label/annotation that 
is defined in the dynamic pod can break the executor 
(dag_id/task_id/try_number/run_id/map_index/kubernetes_executor/etc). 
Basically, we want to allow only overriding of namespace/image but the 
suggested approach allows us to override any value. My suggestion is to split 
`dynamic_pod` into optional (allowed to override) and required (denied to 
override):
   ```
   optional_dynamic_pod = k8s.V1Pod(
       metadata=k8s.V1ObjectMeta(namespace=namespace),
       spec=k8s.V1PodSpec(containers=[k8s.V1Container(image=image)]),
   )
   
   required_dynamic_pod = k8s.V1Pod(
       metadata=k8s.V1ObjectMeta(
           annotations=annotations,
           name=PodGenerator.make_unique_pod_id(pod_id),
           labels=labels,
       ),
       spec=k8s.V1PodSpec(
           containers=[
               k8s.V1Container(
                   name="base",
                   args=args,
                   env=[k8s.V1EnvVar(name="AIRFLOW_IS_K8S_EXECUTOR_POD", 
value="True")],
               ),
           ],
       ),
   )
   
   pod_list = [base_worker_pod, optional_dynamic_pod, pod_override_object, 
required_dynamic_pod]
   ```
   
   Also, regardless of implementation, this part of the function should be 
removed as it's no longer needed. 
   ```
           try:
               image = pod_override_object.spec.containers[0].image  # type: 
ignore
               if not image:
                   image = kube_image
           except Exception:
               image = kube_image
   ```


-- 
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]

Reply via email to