diff --git a/providers/src/airflow/providers/cncf/kubernetes/operators/job.py b/providers/src/airflow/providers/cncf/kubernetes/operators/job.py index 91ff5fa40ec0b..a55c776913a4e 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/operators/job.py +++ b/providers/src/airflow/providers/cncf/kubernetes/operators/job.py @@ -273,7 +273,6 @@ 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), } if self.termination_grace_period is not None: kwargs.update(grace_period_seconds=self.termination_grace_period) diff --git a/providers/tests/cncf/kubernetes/operators/test_job.py b/providers/tests/cncf/kubernetes/operators/test_job.py index 1be3d80217dfb..5342363f0939d 100644 --- a/providers/tests/cncf/kubernetes/operators/test_job.py +++ b/providers/tests/cncf/kubernetes/operators/test_job.py @@ -686,13 +686,10 @@ def test_execute_complete_fail(self): @pytest.mark.non_db_test_override @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.job_client")) - @patch(HOOK_CLASS) - def test_on_kill(self, mock_hook, mock_client): + def test_on_kill(self, mock_client): mock_job = mock.MagicMock() mock_job.metadata.name = JOB_NAME mock_job.metadata.namespace = JOB_NAMESPACE - mock_serialize = mock_hook.return_value.batch_v1_client.api_client.sanitize_for_serialization - mock_serialized_job = mock_serialize.return_value op = KubernetesJobOperator(task_id="test_task_id") op.job = mock_job @@ -701,19 +698,14 @@ def test_on_kill(self, mock_hook, mock_client): mock_client.delete_namespaced_job.assert_called_once_with( name=JOB_NAME, namespace=JOB_NAMESPACE, - job=mock_serialized_job, ) - mock_serialize.assert_called_once_with(mock_job) @pytest.mark.non_db_test_override @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.job_client")) - @patch(HOOK_CLASS) - def test_on_kill_termination_grace_period(self, mock_hook, mock_client): + def test_on_kill_termination_grace_period(self, mock_client): mock_job = mock.MagicMock() mock_job.metadata.name = JOB_NAME mock_job.metadata.namespace = JOB_NAMESPACE - mock_serialize = mock_hook.return_value.batch_v1_client.api_client.sanitize_for_serialization - mock_serialized_job = mock_serialize.return_value mock_termination_grace_period = mock.MagicMock() op = KubernetesJobOperator( @@ -725,10 +717,8 @@ def test_on_kill_termination_grace_period(self, mock_hook, mock_client): mock_client.delete_namespaced_job.assert_called_once_with( name=JOB_NAME, namespace=JOB_NAMESPACE, - job=mock_serialized_job, grace_period_seconds=mock_termination_grace_period, ) - mock_serialize.assert_called_once_with(mock_job) @pytest.mark.non_db_test_override @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.client"))