Skip to content

Commit

Permalink
Implement argo delete job
Browse files Browse the repository at this point in the history
  • Loading branch information
totycro committed Sep 19, 2024
1 parent 64ea340 commit f60a182
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pygeoapi_kubernetes_papermill/argo.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,14 @@ def delete_job(self, job_id) -> bool:
:returns: `bool` of status result
"""
raise NotImplementedError
self.custom_objects_api.delete_namespaced_custom_object(
**K8S_CUSTOM_OBJECT_WORKFLOWS,
name=k8s_job_name(job_id=job_id),
namespace=self.namespace,
# this policy should also remove pods, but doesn't
propagation_policy="Foreground",
)
return True

def _execute_handler_async(
self,
Expand Down
19 changes: 19 additions & 0 deletions tests/test_argo_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ def test_get_jobs_returns_workflows(
assert job["identifier"] == "annotations-identifier"


def test_delete_job_deletes_job(
manager: ArgoManager,
mock_delete_workflow,
):
response = manager.delete_job("abc")

assert response
mock_delete_workflow.assert_called()


@pytest.fixture()
def mock_create_workflow():
with mock.patch(
Expand Down Expand Up @@ -175,3 +185,12 @@ def mock_list_workflows():
return_value={"items": [MOCK_WORKFLOW]},
) as mocker:
yield mocker


@pytest.fixture()
def mock_delete_workflow():
with mock.patch(
"pygeoapi_kubernetes_papermill."
"kubernetes.k8s_client.CustomObjectsApi.delete_namespaced_custom_object",
) as mocker:
yield mocker

0 comments on commit f60a182

Please sign in to comment.