kaxil commented on a change in pull request #9903:
URL: https://github.com/apache/airflow/pull/9903#discussion_r458221946



##########
File path: airflow/kubernetes/pod_launcher.py
##########
@@ -63,7 +63,16 @@ def __init__(self,
 
     def run_pod_async(self, pod, **kwargs):
         """Runs POD asynchronously"""
-        pod_mutation_hook(pod)
+        import airflow.configuration as conf
+        if conf.get("kubernetes", "pod_mutation_using_k8s_pod"):
+            pod_mutation_hook(pod)
+        else:
+            from airflow.kubernetes.pod import Pod
+            from airflow.kubernetes.pod_generator import PodGenerator
+            dummy_pod = Pod(image="", envs={}, cmds=[])
+            pod_mutation_hook(dummy_pod)
+            dummy_pod = dummy_pod.to_v1_kubernetes_pod()
+            PodGenerator.reconcile_pods(pod, dummy_pod)

Review comment:
       The change in PR won't work if we have the following in our 
``airflow_local_settings.py`` (We have this for Astronomer- Airflow chart) 
since the pod labels would show up as `{}`:
   
   ```python
       def pod_mutation_hook(pod: Pod):
           extra_labels = {
               "kubernetes_executor": "False",
               "kubernetes_pod_operator": "False"
           }
           if 'airflow-worker' in pod.labels.keys() or \
                   conf.get('core', 'EXECUTOR') == "KubernetesExecutor":
               extra_labels["kubernetes_executor"] = "True"
           else:
               extra_labels["kubernetes_pod_operator"] = "True"
   ```




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


Reply via email to