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



##########
File path: airflow/kubernetes/pod_generator.py
##########
@@ -324,47 +325,36 @@ def add_sidecar(pod: k8s.V1Pod) -> k8s.V1Pod:
     @staticmethod
     def from_obj(obj) -> Optional[k8s.V1Pod]:
         """Converts to pod from obj"""
+
         if obj is None:
             return None
 
-        if isinstance(obj, PodGenerator):
-            return obj.gen_pod()
-
-        if not isinstance(obj, dict):
-            raise TypeError(
-                'Cannot convert a non-dictionary or non-PodGenerator '
-                'object into a KubernetesExecutorConfig')
+        k8s_legacy_object = obj.get("KubernetesExecutor", None)
+        k8s_object = obj.get("podOverride", None)
 
-        # We do not want to extract constant here from ExecutorLoader because 
it is just
-        # A name in dictionary rather than executor selection mechanism and it 
causes cyclic import
-        namespaced = obj.get("KubernetesExecutor", {})
-
-        if not namespaced:
+        if k8s_legacy_object and k8s_object:
+            raise AirflowConfigException("Can not have both a legacy and new"
+                                         "executor_config object. Please 
delete the KubernetesExecutor"
+                                         "dict and only use the podOverride 
kubernetes.client.models.V1Pod"
+                                         "object.")
+        if not k8s_object and not k8s_legacy_object:
             return None
 
-        resources = namespaced.get('resources')
+        if isinstance(k8s_object, k8s.V1Pod):
+            return k8s_object
 

Review comment:
       ```suggestion
   ```




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