Repository navigation
daemon/cluster: Cluster.imageWithDigestString: include mirrors to resolve digest - #47024
Conversation
…olve digest If the daemon is configured to use a mirror for the default (Docker Hub) registry, the endpoint did not fall back to querying the upstream if the mirror did not contain the given reference. For pull-through registry-mirrors, this was not a problem, as in that case the registry would forward the request, but for other mirrors, no fallback would happen. This was inconsistent with how "pulling" images handled this situation; when pulling images, both the mirror and upstream would be tried. This patch brings the daemon-side lookup of image-manifests on-par with the client-side lookup (the GET /distribution endpoint) as used in API 1.30 and higher. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
9ffd11c to
07d2ad3
Compare
|
FWIW; I kept this one separate from #47023, as this is only fixing a code-path for API < 1.30, and I was on the fence if it was worth fixing / changing behavior for old API versions. We never received reports (that I'm aware of) for this case, but OTOH, it cleans up the extra function, and we have not yet deprecated API 1.30 in #46887). If possible we should also move this part to the API (I think), and adjust behavior there, but I'd have to have a closer look if that's possible (it may depend on other parts of "service") |
corhere
left a comment
There was a problem hiding this comment.
It's a tough call. Someone might be depending on the buggy behaviour. Since there is no way to explicitly opt out of resolving the image to a digest on API <v1.30, they might even have intentionally crafted an environment which triggers the bug in order to prevent image tags from being resolved to digests. However I can't imagine that being terribly useful or desirable. You'd have to manually pull the updated images into each node's image cache to roll out an update with a moving tag.
A more plausible "breakage" scenario after fixing this bug would be users running docker service update triggering a rollout of an updated image for the first time in months/years and having the (unknowingly untested) new images break in production. They may blame the daemon upgrade because as far as they know the images were tested and worked previously. On the other hand, they'd run into issues sooner or later regardless, particularly if a task gets rescheduled onto a new node which doesn't already have the stale image cached.
In either scenario, they would also have been "affected" by a client upgrade.
Given that the API contract pre-v1.30 was to pin the image digest whenever possible, I think it's a fair argument that fixing the bug would not be a violation. The users in my second scenario would start to see the behaviour they had always expected, and the Hyrum's Law abusers in the first scenario would have a workaround in the form of upgrading their client and explicitly opting out of resolving images. I'm good with merging this so long as we call this change out in the release notes and describe how users could be impacted.
|
I think the Or maybe I have my wires crossed there 🤔 ( |
|
Oh yeah, I now see the behaviour is a bit more subtle. Any update to a container-type task pre-v1.30 triggers a resolve of the image reference. Since the image reference gets overwritten in-place, any references which were previously resolved to digests will remain unchanged since the digest reference would be resolved back to the same digest. Any tag references would get resolved to digests on the first service update after the daemon upgrade. moby/daemon/cluster/services.go Lines 360 to 387 in 677d41a |
Yes, indeed! It's all a bit messy, which is also why I was pondering if that code should be moved to the API (considering it adjusting API response, similar to what we do for other cases), but I'd need to have a closer look if possible. Looks like we're ok with this fix; let me bring this one in for v25; I'll add cherry-pick labels if we consider backporting this fix (and #47023) to LTS branches, but we can hold-off doing so (consider the labels a "reminder" so that we don't forget). |
daemon/cluster: Cluster.imageWithDigestString: include mirrors to resolve digest
If the daemon is configured to use a mirror for the default (Docker Hub)
registry, the endpoint did not fall back to querying the upstream if the mirror
did not contain the given reference.
For pull-through registry-mirrors, this was not a problem, as in that case the
registry would forward the request, but for other mirrors, no fallback would
happen. This was inconsistent with how "pulling" images handled this situation;
when pulling images, both the mirror and upstream would be tried.
This patch brings the daemon-side lookup of image-manifests on-par with the
client-side lookup (the GET /distribution endpoint) as used in API 1.30 and
higher.
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)