Proxy cache: concurrent pulls of an uncached blob each download it from upstream
Expected behavior and actual behavior:
Expected: if a blob is already being pulled from upstream for a proxy-cache project, another pull of that same blob should wait on that fetch instead of starting a new one. A single pull also should not transfer the blob twice.
Actual: each blob GET opens its own upstream connection and streams it to the client. ProxyBlob then starts putBlobToLocal in the background, which opens a second connection for the same digest. The inflight check in PushBlob only skips the local push, and it runs after that second download has already started. It does not apply to the bytes sent to the client.
We saw this on a large image that was not cached yet (gitea/runner-images:ubuntu-latest). Two overlapping pulls of the same layers (including stopping one pull and starting another before the layer finished) showed different progress, and both kept climbing slowly. Same thing when several pods pull one image at once: each node burns a full upstream download.
Steps to reproduce the problem:
- Use a proxy-cache project and an image that is not in the local cache, with at least one large layer.
- Pull it twice at the same time. Two clients, or cancel the first pull and start it again while the layer is still downloading.
- Watch the layer progress. The same blob moves on its own in each pull. The second one does not catch up to what the first one already received.
Versions:
- harbor version: v2.15.2
- docker engine version: reproduced with podman
- docker-compose version: n/a
Additional context:
The paths are ProxyBlob / putBlobToLocal in src/controller/proxy/controller.go, the same pattern in src/controller/proxy/manifestcache.go, and the inflight check in PushBlob (src/controller/proxy/local.go).
Source: goharbor/harbor