Skip to content

[20.10] Fallback to manifest list when no platform match#42045

Merged
thaJeztah merged 2 commits into
moby:20.10from
cpuguy83:20.10_fallback_manifest_on_bad_plat
Feb 18, 2021
Merged

[20.10] Fallback to manifest list when no platform match#42045
thaJeztah merged 2 commits into
moby:20.10from
cpuguy83:20.10_fallback_manifest_on_bad_plat

Conversation

@cpuguy83

@cpuguy83 cpuguy83 commented Feb 18, 2021

Copy link
Copy Markdown
Member

Cherry-pick #41955
relates to / addresses docker/for-linux#1170 (comment)


In some cases, in fact many in the wild, an image may have the incorrect
platform on the image config.
This can lead to failures to run an image, particularly when a user
specifies a --platform.
Typically what we see in the wild is a manifest list with an an entry
for, as an example, linux/arm64 pointing to an image config that has
linux/amd64 on it.

This change falls back to looking up the manifest list for an image to
see if the manifest list shows the image as the correct one for that
platform.

In order to accomplish this we need to traverse the leases associated
with an image. Each image, if pulled with Docker 20.10, will have the
manifest list stored in the containerd content store with the resource
assigned to a lease keyed on the image ID.
So we look up the lease for the image, then look up the assocated
resources to find the manifest list, then check the manifest list for a
platform match, then ensure that manifest referes to our image config.

This is only used as a fallback when a user specified they want a
particular platform and the image config that we have does not match
that platform.

In some cases, in fact many in the wild, an image may have the incorrect
platform on the image config.
This can lead to failures to run an image, particularly when a user
specifies a `--platform`.
Typically what we see in the wild is a manifest list with an an entry
for, as an example, linux/arm64 pointing to an image config that has
linux/amd64 on it.

This change falls back to looking up the manifest list for an image to
see if the manifest list shows the image as the correct one for that
platform.

In order to accomplish this we need to traverse the leases associated
with an image. Each image, if pulled with Docker 20.10, will have the
manifest list stored in the containerd content store with the resource
assigned to a lease keyed on the image ID.
So we look up the lease for the image, then look up the assocated
resources to find the manifest list, then check the manifest list for a
platform match, then ensure that manifest referes to our image config.

This is only used as a fallback when a user specified they want a
particular platform and the image config that we have does not match
that platform.

Signed-off-by: Brian Goff <[email protected]>
(cherry picked from commit 4be5453)
Signed-off-by: Brian Goff <[email protected]>
Wrap platforms.Only and fallback to our ignore mismatches due to  empty
CPU variants. This just cleans things up and makes the logic re-usable
in other places.

Signed-off-by: Brian Goff <[email protected]>
(cherry picked from commit 50f39e7)
Signed-off-by: Brian Goff <[email protected]>

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah
thaJeztah enabled auto-merge February 18, 2021 20:37
@thaJeztah
thaJeztah merged commit df2cfb4 into moby:20.10 Feb 18, 2021
@cpuguy83
cpuguy83 deleted the 20.10_fallback_manifest_on_bad_plat branch February 18, 2021 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants