kaxil commented on a change in pull request #10393:
URL: https://github.com/apache/airflow/pull/10393#discussion_r477522918
##########
File path: airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
##########
@@ -365,43 +351,53 @@ def create_new_pod_for_operator(self, labels, launcher)
-> Tuple[State, k8s.V1Po
}
)
self.labels.update(labels)
- pod = pod_generator.PodGenerator(
- image=self.image,
- namespace=self.namespace,
- cmds=self.cmds,
- args=self.arguments,
- labels=self.labels,
- name=self.name,
- envs=self.env_vars,
- extract_xcom=self.do_xcom_push,
- image_pull_policy=self.image_pull_policy,
- node_selectors=self.node_selectors,
- annotations=self.annotations,
- affinity=self.affinity,
- image_pull_secrets=self.image_pull_secrets,
- service_account_name=self.service_account_name,
- hostnetwork=self.hostnetwork,
- tolerations=self.tolerations,
- configmaps=self.configmaps,
- security_context=self.security_context,
- dnspolicy=self.dnspolicy,
- schedulername=self.schedulername,
- init_containers=self.init_containers,
- restart_policy='Never',
- priority_class_name=self.priority_class_name,
- pod_template_file=self.pod_template_file,
- pod=self.full_pod_spec,
- ).gen_pod()
-
- pod = append_to_pod(
- pod,
- self.pod_runtime_info_envs +
- self.ports + # type: ignore
- self.resources +
- self.secrets + # type: ignore
- self.volumes + # type: ignore
- self.volume_mounts # type: ignore
- )
+ if self.pod_template_file:
+ pod =
pod_generator.PodGenerator.deserialize_model_file(self.pod_template_file)
+ else:
+ pod = k8s.V1Pod(
+ api_version="v1",
+ kind="Pod",
+ metadata=k8s.V1ObjectMeta(
+ namespace=self.namespace,
+ labels=self.labels,
+ name=self.name,
+ annotations=self.annotations,
+
+ ),
+ spec=k8s.V1PodSpec(
+ node_selector=self.node_selectors,
+ affinity=self.affinity,
+ tolerations=self.tolerations,
+ init_containers=self.init_containers,
+ containers=[
+ k8s.V1Container(
+ image=self.image,
+ name="base",
+ command=self.cmds,
+ ports=self.ports,
+ resources=self.k8s_resources,
+ volume_mounts=self.volume_mounts,
+ args=self.arguments,
+ env=self.env_vars,
+ env_from=self.env_from,
+ )
+ ],
+ image_pull_secrets=self.image_pull_secrets,
+ service_account_name=self.service_account_name,
+ host_network=self.hostnetwork,
+ security_context=self.security_context,
+ dns_policy=self.dnspolicy,
+ scheduler_name=self.schedulername,
+ restart_policy='Never',
+ priority_class_name=self.priority_class_name,
+ volumes=self.volumes,
+ )
+ )
+ for secret in self.secrets:
+ pod = secret.attach_to_pod(pod)
+ if self.do_xcom_push:
+ from airflow.kubernetes.pod_generator import PodGenerator
+ pod = PodGenerator.add_xcom_sidecar(pod)
Review comment:
```suggestion
pod = pod_generator.PodGenerator.add_xcom_sidecar(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]