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



##########
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:
       Same comment as above:
   
   I think we will need to support both for 1.10.12 since some of the users 
have already updated their `pod_mutation_hook` to use k8s.V1Pod. So instead of 
a config we can infer the type of the Pod object and use one or the other 
accordingly
   
   We could just check the type of the Pod that is passed, example:
   
   
   ```
   if isinstance(k8s.V1Pod):
       # Use Pod from k8s api
       ....
   else:
       # Use Pod from Airflow POD
   ```
   
   

##########
File path: airflow/config_templates/config.yml
##########
@@ -2173,6 +2173,13 @@
       type: string
       example: ~
       default: ""
+    - name: pod_mutation_using_k8s_pod

Review comment:
       I think we will need to support both for 1.10.12 since some of the users 
have already updated their `pod_mutation_hook` to use k8s.V1Pod. So instead of 
a config we can infer the type of the Pod object and use one or the other 
accordingly
   
   We could just check the type of the Pod that is passed, example:
   
   
   ```
   if isinstance(k8s.V1Pod):
       # Use Pod from k8s api
       ....
   else:
       # Use Pod from Airflow POD
   ```
   
   




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