Exemplo n.º 1
0
def _monitor_runs():
    db_session = create_session()
    try:
        for kind in RuntimeKinds.runtime_with_handlers():
            try:
                runtime_handler = get_runtime_handler(kind)
                runtime_handler.monitor_runs(get_db(), db_session)
            except Exception as exc:
                logger.warning(
                    "Failed monitoring runs. Ignoring", exc=str(exc), kind=kind
                )
    finally:
        close_session(db_session)
Exemplo n.º 2
0
def _cleanup_runtimes():
    db_session = create_session()
    try:
        for kind in RuntimeKinds.runtime_with_handlers():
            try:
                runtime_handler = get_runtime_handler(kind)
                runtime_handler.delete_resources(get_db(), db_session)
            except Exception as exc:
                logger.warning(
                    "Failed deleting resources. Ignoring", exc=str(exc), kind=kind
                )
    finally:
        close_session(db_session)
Exemplo n.º 3
0
def delete_runtime_object(kind: str,
                          object_id: str,
                          label_selector: str = None,
                          force: bool = False,
                          db_session: Session = Depends(deps.get_db_session)):
    if kind not in RuntimeKinds.runtime_with_handlers():
        log_and_raise(status.HTTP_400_BAD_REQUEST,
                      kind=kind,
                      err='Invalid runtime kind')
    runtime_handler = get_runtime_handler(kind)
    runtime_handler.delete_runtime_object_resources(get_db(), db_session,
                                                    object_id, label_selector,
                                                    force)
    return Response(status_code=status.HTTP_204_NO_CONTENT)
Exemplo n.º 4
0
def delete_runtime(
        kind: str,
        label_selector: str = None,
        force: bool = False,
        grace_period: int = config.runtime_resources_deletion_grace_period,
        db_session: Session = Depends(deps.get_db_session),
):
    if kind not in RuntimeKinds.runtime_with_handlers():
        log_and_raise(HTTPStatus.BAD_REQUEST.value,
                      kind=kind,
                      err="Invalid runtime kind")
    runtime_handler = get_runtime_handler(kind)
    runtime_handler.delete_resources(get_db(), db_session, label_selector,
                                     force, grace_period)
    return Response(status_code=HTTPStatus.NO_CONTENT.value)