Skip to content

Conversation

@MaksYermak
Copy link
Contributor

In this PR I have fixed usage for do_xcom_push and get_logs functionality for KubernetesJobOperator in deferrable and non-deferrable modes.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues provider:google Google (including GCP) related issues labels Jul 16, 2024
@VladaZakharova
Copy link
Contributor

Hi @romsharon98 and @amoghrajesh ! can you please check changes here? Thanks!

@VladaZakharova
Copy link
Contributor

VladaZakharova commented Aug 22, 2024

Hi @romsharon98, @amoghrajesh @potiuk @eladkal @hussein-awala !
Can you please check changes here?

@potiuk potiuk merged commit 170b9ce into apache:main Aug 22, 2024
1 check passed
@ccardi
Copy link

ccardi commented Sep 30, 2024

Not working on GKE Autopilot. Need to set get_logs=False.
Otherwise: pod_name is not defined.


ERROR - Task failed with exception
Traceback (most recent call last):
File "/opt/python3.11/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 465, in _execute_task
result = _execute_callable(context=context, **execute_callable_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python3.11/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 432, in _execute_callable
return execute_callable(context=context, **execute_callable_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python3.11/lib/python3.11/site-packages/airflow/models/baseoperator.py", line 1724, in resume_execution
return execute_callable(context)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/gcs/dags/dag_gke_pod-simple-pi-joboperator.py", line 30, in execute_complete
super().execute_complete(context, event)
File "/opt/python3.11/lib/python3.11/site-packages/airflow/providers/cncf/kubernetes/operators/job.py", line 233, in execute_complete
pod_name = event["pod_name"]

KeyError: 'pod_name'

Comment on lines +169 to +173
if self.pod is None:
self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
pod_request_obj=self.pod_request_obj,
context=context,
)
Copy link

@NilsIrl NilsIrl Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work if the pod wasn't already created by the time this is reached? Won't 2 pods eventually get created (when the job eventually creates the pod)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same question. I thought the K8s Job will manage the pod creations, why would we need creating the pod manually again? I'm actually running into bugs where I set parallelism to more than 1 and this line triggers self.find_pods() which triggers

raise AirflowException(f"More than one pod running with labels {label_selector}")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steinwaywhw can you explain your problem more? Would you like to take a stab at fixing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @steinwaywhw,
It's a known issue #44994 and the fix was already prepared by this PR #49899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants