daemon: Don't set empty platform for GetImageOpts#131
Open
daemon: Don't set empty platform for GetImageOpts#131
Conversation
Don't set `GetImageOpts.Platform` to avoid searching for `unknown/unknown` platform in image, when for some reason the `container.Config.Platform` is empty. This is possible for containers created before `run --platform X` support was added. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
thaJeztah
reviewed
Jan 28, 2023
| return nil, err | ||
| } | ||
| opts.Platform = &ctr.Config.Platform | ||
| if ctr.Config.Platform.OS != "" { |
Collaborator
There was a problem hiding this comment.
Do we always set a normalised Platform ? (i.e., --platform=arm64 gets normalised to linux/arm64?) ISTR fields can be treated as "optional", so if we would not normalise the value, OS could be empty, but Arch possibly not.
Looking at this, I wonder if sending a nil platform is actually problematic;
daemon.imageService.GetImage()- calls
imageService.getImage() - calls
imageService.GetContainerdImage() - calls (is a wrapper for)
imageService.resolveImage()
That last one may be problematic if we do not specify a platform;
moby/daemon/containerd/image.go
Lines 149 to 152 in a723ff5
It looks like that function returns;
- a manifest index if no platform is specified
- an image manifest (image) if a platform is specified'
- (or a "not found" if the image was found, but no matching platform)
Which means that we would now switch the container from referencing an image to it referencing a manifest list (?)
I wonder if instead of "no platform", we should either;
- Set the default platform (I think that's also what would be used if no platform is specified
- Or to look up the container's image ID, and check the image's platform?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Don't set
GetImageOpts.Platformto avoid searching forunknown/unknownplatform in image, when for some reason thecontainer.Config.Platformis empty.This is possible for containers created before
run --platform Xsupport was added.Signed-off-by: Paweł Gronowski pawel.gronowski@docker.com
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)