fix(portal): resolve 10+ sec link delay by fixing Garage S3 secret key, adding 1s boto3 timeouts, and running S3 list calls in parallel
This commit is contained in:
@@ -11,6 +11,7 @@ Every page renders against the design tokens in static/tokens.css.
|
|||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from zoneinfo import ZoneInfo
|
from zoneinfo import ZoneInfo
|
||||||
@@ -206,11 +207,13 @@ async def tool_embed(request: Request, tool_id: str) -> HTMLResponse:
|
|||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
request, "not_found.html", {"user": user}, status_code=404
|
request, "not_found.html", {"user": user}, status_code=404
|
||||||
)
|
)
|
||||||
# Workspace files: the user's bucket + the shared pool (does not block the
|
# Workspace files: the user's bucket + the shared pool (runs concurrently,
|
||||||
# event loop, degrades to empty list on any S3 error).
|
# degraded gracefully on any S3 error/timeout).
|
||||||
user_bucket = s3_bucket_name(user.username)
|
user_bucket = s3_bucket_name(user.username)
|
||||||
my_files = await run_in_threadpool(list_recent, user_bucket, 20)
|
my_files, shared_files = await asyncio.gather(
|
||||||
shared_files = await run_in_threadpool(list_recent, "shared-media", 20)
|
run_in_threadpool(list_recent, user_bucket, 20),
|
||||||
|
run_in_threadpool(list_recent, "shared-media", 20),
|
||||||
|
)
|
||||||
ctx = {
|
ctx = {
|
||||||
"user": user,
|
"user": user,
|
||||||
"tool": tool,
|
"tool": tool,
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ def s3_client():
|
|||||||
region_name=settings.S3_REGION or None,
|
region_name=settings.S3_REGION or None,
|
||||||
aws_access_key_id=settings.S3_ACCESS_KEY or None,
|
aws_access_key_id=settings.S3_ACCESS_KEY or None,
|
||||||
aws_secret_access_key=settings.S3_SECRET_KEY or None,
|
aws_secret_access_key=settings.S3_SECRET_KEY or None,
|
||||||
config=Config(signature_version="s3v4"),
|
config=Config(
|
||||||
|
signature_version="s3v4",
|
||||||
|
connect_timeout=1,
|
||||||
|
read_timeout=1,
|
||||||
|
retries={"max_attempts": 1},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user