Skip to content

Implement deferrable mode for KubernetesJobOperator - #38251

Merged
potiuk merged 1 commit into
apache:mainfrom
VladaZakharova:k8s-start-job-deferrable
Mar 22, 2024
Merged

potiuk merged 1 commit into
apache:mainfrom
VladaZakharova:k8s-start-job-deferrable

Conversation

@moiseenkov

Copy link
Copy Markdown
Contributor

Implement deferrable mode for KubernetesJobOperator.

@moiseenkov
moiseenkov force-pushed the k8s-start-job-deferrable branch 4 times, most recently from ccfe02b to e925ce8 Compare March 18, 2024 12:37
@potiuk
potiuk force-pushed the k8s-start-job-deferrable branch from e925ce8 to 6f10815 Compare March 18, 2024 13:11
@moiseenkov
moiseenkov force-pushed the k8s-start-job-deferrable branch 17 times, most recently from 456fb4e to 801a8a0 Compare March 21, 2024 13:43
@moiseenkov
moiseenkov force-pushed the k8s-start-job-deferrable branch from 801a8a0 to 64d7e2d Compare March 22, 2024 08:18
@moiseenkov

Copy link
Copy Markdown
Contributor Author

@potiuk , @jedcunningham, @hussein-awala, hi
Could you please review and merge this PR?
Thank you!

kwargs = {
"name": job.metadata.name,
"namespace": job.metadata.namespace,
"job": self.hook.batch_v1_client.api_client.sanitize_for_serialization(self.job),

@marekhanus marekhanus Nov 1, 2024 •

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants