Stop long prunes failing with a bare 500 (0.60.1)
A prune that deletes a lot of data (image prune -a in particular) easily runs past docker-py's 60s read timeout. requests' ReadTimeout is not a DockerException, so it slipped past safe_call and the UI only showed "Request failed with status code 500". Prunes now use a client with a 540s timeout (below nginx's 600s proxy_read_timeout), and safe_call turns transport timeouts and connection errors into DockerError, so they surface as a 502 with a message. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8edea8f971
commit
f766ded528
7 files changed
+120
-11
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"""Image listing for the images router."""
|
||||
from __future__ import annotations
|
||||
|
||||
from docker_client import DockerError, get_client, safe_call
|
||||
from docker_client import DockerError, get_client, get_long_client, safe_call
|
||||
from services import update_service
|
||||
|
||||
COMPOSE_PROJECT_LABEL = "com.docker.compose.project"
|
||||
@@ -51,7 +51,7 @@ def prune_images(all_unused: bool = False) -> dict:
|
||||
"""Remove unused images. By default only dangling (untagged) images are
|
||||
removed; ``all_unused=True`` removes every image not referenced by a
|
||||
container (``docker image prune -a``)."""
|
||||
client = get_client()
|
||||
client = get_long_client()
|
||||
# dangling=false tells the engine to also consider tagged-but-unused images.
|
||||
filters = {"dangling": False} if all_unused else {"dangling": True}
|
||||
result = safe_call(client.images.prune, filters=filters)
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import Optional
|
||||
from docker.errors import APIError
|
||||
from docker.types import IPAMConfig, IPAMPool
|
||||
|
||||
from docker_client import DockerError, get_client, safe_call
|
||||
from docker_client import DockerError, get_client, get_long_client, safe_call
|
||||
|
||||
COMPOSE_PROJECT_LABEL = "com.docker.compose.project"
|
||||
DEFAULT_NETWORKS = {"bridge", "host", "none"}
|
||||
@@ -133,5 +133,5 @@ def delete_network(network_id: str) -> None:
|
||||
|
||||
|
||||
def prune_networks() -> dict:
|
||||
client = get_client()
|
||||
client = get_long_client()
|
||||
return safe_call(client.networks.prune)
|
||||
@@ -7,7 +7,7 @@ from typing import Literal, Optional
|
||||
|
||||
import yaml
|
||||
|
||||
from docker_client import get_client, safe_call
|
||||
from docker_client import get_client, get_long_client, safe_call
|
||||
|
||||
COMPOSE_PROJECT_LABEL = "com.docker.compose.project"
|
||||
|
||||
@@ -86,7 +86,7 @@ def remove_volume(name: str, force: bool = False) -> None:
|
||||
|
||||
|
||||
def prune_volumes() -> dict:
|
||||
client = get_client()
|
||||
client = get_long_client()
|
||||
return safe_call(client.volumes.prune)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user