marekhanus commented on code in PR #38251:
URL: https://github.com/apache/airflow/pull/38251#discussion_r1825797645


##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -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),

Review Comment:
   Hi @moiseenkov, what is the purpose of the `job` argument? I see that it is 
not valid argument for 
[delete_namespaced_job](https://github.com/kubernetes-client/python/blob/v31.0.0/kubernetes/docs/BatchV1Api.md#parameters-5)
 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
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to