Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pagination] Fix Spammy Pagination Logs on Token Expiry #5612

Merged
merged 25 commits into from
May 22, 2024

Conversation

quaark
Copy link
Member

@quaark quaark commented May 22, 2024

Added functionality of "expected mlrun errors".
When these errors occur and return an error status code via the API, they will not log the whole traceback of the error, and the log line will be debug instead of warning as indeed these errors are expected.

Added a MLRunPaginationEndOfResultsError which is one of these expected errors. This way when the pagination token expires we have a nicer log saying it.

Before:

> 2024-05-22 08:00:07,517 [warning] Request handling returned error status: {"error_message":"MLRunNotFoundError('Token f71020e4512fe0d08f031e6f55cea305b4db0cc7dd404aca9dc3341cfb9e7005 not found in pagination cache')","request_id":"36a74ea1-1096-4ab3-8179-224052eadfdb","status_code":404,"traceback":"Traceback (most recent call last):\n  File \"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n    await app(scope, receive, sender)\n  File \"/usr/local/lib/python3.9/site-packages/starlette/routing.py\", line 72, in app\n    response = await func(request)\n  File \"/usr/local/lib/python3.9/site-packages/fastapi/routing.py\", line 278, in app\n    raw_response = await run_endpoint_function(\n  File \"/usr/local/lib/python3.9/site-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n    return await dependant.call(**values)\n  File \"/mlrun/server/api/api/endpoints/functions.py\", line 235, in list_functions\n    functions, page_info = await paginator.paginate_permission_filtered_request(\n  File \"/mlrun/server/api/utils/pagination.py\", line 115, in paginate_permission_filtered_request\n    new_result, pagination_info = await self.paginate_request(\n  File \"/mlrun/server/api/utils/pagination.py\", line 170, in paginate_request\n    ) = self._create_or_update_pagination_cache_record(\n  File \"/mlrun/server/api/utils/pagination.py\", line 221, in _create_or_update_pagination_cache_record\n    raise mlrun.errors.MLRunNotFoundError(\nmlrun.errors.MLRunNotFoundError: Token f71020e4512fe0d08f031e6f55cea305b4db0cc7dd404aca9dc3341cfb9e7005 not found in pagination cache\n"}

After:

> 2024-05-22 11:52:36,290 [debug] Request handling returned error status: {"error_message":"MLRunPaginationEndOfResultsError('Token b2d5fe0f24e7d4e1d72c0b207f1193f9ac7ad4dd29b2f02d26959fc472c459a9 not found in pagination cache')","request_id":"31b7d405-1727-42ea-a53d-806da79ebada","status_code":404}

quaark added 24 commits April 3, 2024 11:05
server/api/main.py Outdated Show resolved Hide resolved
@quaark quaark merged commit 9345658 into mlrun:development May 22, 2024
11 checks passed
rokatyy pushed a commit to rokatyy/mlrun that referenced this pull request May 28, 2024
* Less spammy logs

* CR

---------

Co-authored-by: quaark <a.melnick@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants