johngtam edited a comment on issue #10290:
URL: https://github.com/apache/airflow/issues/10290#issuecomment-1062404161


   @eladkal, I'm not OP, but I can confirm this still happens on 2.0.2 -- 
looking at more of the codeflow:
   
   ```
           dynamic_pod = k8s.V1Pod(
               metadata=k8s.V1ObjectMeta(
                   namespace=namespace,
                   annotations=annotations,
                   name=PodGenerator.make_unique_pod_id(pod_id),
                   labels=labels,
               ),
               spec=k8s.V1PodSpec(
                   containers=[
                       k8s.V1Container(
                           name="base",
                           args=args,
                           image=image,
                           
env=[k8s.V1EnvVar(name="AIRFLOW_IS_K8S_EXECUTOR_POD", value="True")],
                       )
                   ]
               ),
           )
   
           # Reconcile the pods starting with the first chronologically,
           # Pod from the pod_template_File -> Pod from executor_config arg -> 
Pod from the K8s executor
           pod_list = [base_worker_pod, pod_override_object, dynamic_pod]
   
           return reduce(PodGenerator.reconcile_pods, pod_list)
   ```
   
   I see here that dynamic pod takes precedence. This dynamic pod gets its 
namespace from the caller of this method. Looking at the callers of this method 
[here](https://github.com/apache/airflow/blob/ac77c89018604a96ea4f5fba938f2fbd7c582793/airflow/executors/kubernetes_executor.py#L314),
 
[here](https://github.com/apache/airflow/blob/5ace37a16d1773adb71c684450838e4c8e69b581/airflow/models/taskinstance.py#L2101),
 and 
[here](https://github.com/apache/airflow/blob/dc1fd89a5b95a2424737371cc2d31edea3030247/airflow/cli/commands/kubernetes_command.py#L47),
 I search through the code to find out where the namespace is coming from.
   
   If it's coming from `kube_config.executor_namespace`, I can see where it's 
coming from 
[here](https://github.com/apache/airflow/blob/5ace37a16d1773adb71c684450838e4c8e69b581/airflow/kubernetes/kube_config.py#L53).
 Therefore, going from the code block above, dynamic_pod's namespace takes 
precedence, and that is determined from the config's namespace.
   
   Therefore, dynamic_pod will ultimately override namespace without regard to 
`pod_override`, because there can only be one namespace. Going to explore 
upgrading Airflow on my own (but currently going with a workaround before 
then), but it doesn't seem like this particular code flow has changed much -- 
might be worth verifying on part of the Airflow maintainers? 


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