mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-29 08:54:34 +02:00
feat: report Docker pull progress and add an idle timeout
A pull now reports docker.image.pull notifications on the controller stream: started, throttled downloading events with the layer counts and the latest daemon message, then completed or failed. An optional progress_id is echoed in every event so a client can correlate them with its own request. Image operations belong to a compute, not to a project, so the events go to the controller stream and reach clients that have no project open. The pull also has an idle socket read timeout of 60 seconds. Without it an unreachable registry left the pull, the compute request and the client request hanging forever with no feedback at all. The timeout is idle time, not total time: the daemon streams progress during the whole pull, so a minute without data means the registry is gone. When it fires, the daemon connection closes and Docker cancels the pull. Docker.http_query now accepts an aiohttp ClientTimeout object so a caller can ask for a policy finer than a total timeout.
This commit is contained in:
9 files changed
+266
-27
No files matched your search
@@ -215,16 +215,26 @@ async def docker_get_images(compute_id: Union[str, UUID]) -> List[schemas.Comput
|
||||
dependencies=[Depends(has_privilege("Compute.Modify"))],
|
||||
)
|
||||
async def docker_pull_image(
|
||||
compute_id: Union[str, UUID], image: str = Body(..., embed=True, min_length=1, pattern=r"^\S+$")
|
||||
compute_id: Union[str, UUID],
|
||||
image: str = Body(..., embed=True, min_length=1, pattern=r"^\S+$"),
|
||||
progress_id: Optional[str] = Query(
|
||||
None, pattern=r"^\S+$", description="Client supplied id to correlate progress notifications"
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Pull or update a Docker image on a compute.
|
||||
|
||||
The pull progress is reported on the controller notification stream as
|
||||
docker.image.pull events (started, downloading, completed or failed). The
|
||||
optional progress_id is echoed in every event so a client can correlate
|
||||
them with its own request.
|
||||
|
||||
Required privilege: Compute.Modify
|
||||
"""
|
||||
|
||||
compute = Controller.instance().get_compute(str(compute_id))
|
||||
await compute.forward("POST", "docker", "images/pull", data={"image": image})
|
||||
params = {"progress_id": progress_id} if progress_id is not None else None
|
||||
await compute.forward("POST", "docker", "images/pull", data={"image": image}, params=params)
|
||||
|
||||
|
||||
@router.post(
|
||||
|
||||
Reference in new issue
Block a user