-
Notifications
You must be signed in to change notification settings - Fork 14.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement deferrable mode for KubernetesJobOperator #38251
Conversation
ccfe02b
to
e925ce8
Compare
e925ce8
to
6f10815
Compare
456fb4e
to
801a8a0
Compare
801a8a0
to
64d7e2d
Compare
@potiuk , @jedcunningham, @hussein-awala, hi |
@@ -188,6 +225,7 @@ def on_kill(self) -> None: | |||
kwargs = { | |||
"name": job.metadata.name, | |||
"namespace": job.metadata.namespace, | |||
"job": self.hook.batch_v1_client.api_client.sanitize_for_serialization(self.job), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @moiseenkov, what is the purpose of the job
argument? I see that it is not valid argument for delete_namespaced_job method.
I'm running on Airflow v2.9.1 and this bad argument causes following error when using KubernetesJobOperator
:
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py", line 465, in _execute_task
result = _execute_callable(context=context, **execute_callable_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py", line 432, in _execute_callable
return execute_callable(context=context, **execute_callable_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py", line 400, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/operators/job.py", line 167, in execute
self.job = self.hook.wait_until_job_complete(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/hooks/kubernetes.py", line 561, in wait_until_job_complete
sleep(job_poll_interval)
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py", line 2612, in signal_handler
self.task.on_kill()
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/operators/job.py", line 232, in on_kill
self.client.delete_namespaced_job(**kwargs)
File "/home/airflow/.local/lib/python3.12/site-packages/kubernetes/client/api/batch_v1_api.py", line 876, in delete_namespaced_job
return self.delete_namespaced_job_with_http_info(name, namespace, **kwargs) # noqa: E501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.12/site-packages/kubernetes/client/api/batch_v1_api.py", line 933, in delete_namespaced_job_with_http_info
raise ApiTypeError(
kubernetes.client.exceptions.ApiTypeError: Got an unexpected keyword argument 'job' to method delete_namespaced_job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @marekhanus ,
This seems to be a bug, and I'm sorry for introducing it. I'd be able to fix it in a couple of weeks. But if you feel you can do it sooner, please feel free to submit your own PR and let me know about it.
Thank you for paying attention to it.
Implement deferrable mode for
KubernetesJobOperator
.