Skip to content

app

delete_app(namespace, app_id, force=False) async

This endpoint deletes a spark application by its app_id.

It deletes the driver pod, then the Kubernetes garbage collector will delete the executor pods and the other resources.

Source code in spark_on_k8s/api/app.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@router.delete(
    "/{namespace}/{app_id}",
    summary="Delete a spark application",
)
async def delete_app(namespace: str, app_id: str, force: bool = False):
    """This endpoint deletes a spark application by its app_id.

    It deletes the driver pod, then the Kubernetes garbage collector
    will delete the executor pods and the other resources.
    """
    async_spark_app_manager = AsyncSparkAppManager(
        k8s_client_manager=KubernetesClientSingleton.client_manager
    )
    try:
        await async_spark_app_manager.delete_app(namespace=namespace, app_id=app_id)
        return Response(status_code=200)
    except Exception as e:
        # TODO: handle exceptions properly and return proper status code
        return handle_exception(e, 500)

kill_app(namespace, app_id) async

This endpoint kills a spark application by its app_id.

It sends a SIGTERM to the init process of the driver pod (PID 1).

Source code in spark_on_k8s/api/app.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@router.patch(
    "/{namespace}/{app_id}",
    summary="Kill a spark application",
)
async def kill_app(namespace: str, app_id: str):
    """This endpoint kills a spark application by its app_id.

    It sends a SIGTERM to the init process of the driver pod (PID 1).
    """
    async_spark_app_manager = AsyncSparkAppManager(
        k8s_client_manager=KubernetesClientSingleton.client_manager
    )
    try:
        await async_spark_app_manager.kill_app(namespace=namespace, app_id=app_id)
        return Response(status_code=200)
    except Exception as e:
        # TODO: handle exceptions properly and return proper status code
        return handle_exception(e, 500)