daemon/images: remove leftover LCOW platform checks

This removes some of the checks that were added in 0cba7740d4,
but should no longer be needed.

- `ImageService.ImageDelete()`: no need to validate image platform to delete it.
- `ImageService.ImageHistory()`: no need to validate image platform to show its
  history; if it made it into the local image cache, it should be valid.
- `ImageService.ImportImage()`: `dockerfile.BuildFromConfig()` is used for
  `docker (container) commmit` and `docker (image) import`. For `docker import`,
   it's more transparent to perform validation early.
- `ImageService.LookupImage()`: no need to validate image platform to inspect it;
  if it made it into the local image cache, it should be valid.
- `ImageService.SquashImage()`: same. This code was actually broken, because it
  wrapped an `err` that was always `nil`, so would never return an error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-01-25 12:15:50 +01:00
parent 559ff0ac66
commit b2ef2e8c83
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 5 additions and 16 deletions

View File

@ -11,7 +11,6 @@ import (
"github.com/docker/docker/errdefs"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/system"
"github.com/pkg/errors"
)
@ -68,9 +67,6 @@ func (i *ImageService) ImageDelete(imageRef string, force, prune bool) ([]types.
if err != nil {
return nil, err
}
if !system.IsOSSupported(img.OperatingSystem()) {
return nil, errors.Errorf("unable to delete image: %q", system.ErrNotSupportedOperatingSystem)
}
imgID := img.ID()
repoRefs := i.referenceStore.References(imgID.Digest())

View File

@ -7,7 +7,6 @@ import (
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/system"
)
// ImageHistory returns a slice of ImageHistory structures for the specified image
@ -32,9 +31,6 @@ func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem,
if len(img.RootFS.DiffIDs) <= layerCounter {
return nil, fmt.Errorf("too many non-empty layers in History section")
}
if !system.IsOSSupported(img.OperatingSystem()) {
return nil, system.ErrNotSupportedOperatingSystem
}
rootFS.Append(img.RootFS.DiffIDs[layerCounter])
l, err := i.layerStore.Get(rootFS.ChainID())
if err != nil {

View File

@ -20,6 +20,7 @@ import (
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/system"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
@ -58,7 +59,9 @@ func (i *ImageService) ImportImage(src string, repository string, platform *spec
p := platforms.DefaultSpec()
platform = &p
}
if !system.IsOSSupported(platform.OS) {
return errdefs.InvalidParameter(system.ErrNotSupportedOperatingSystem)
}
config, err := dockerfile.BuildFromConfig(&container.Config{}, changes, platform.OS)
if err != nil {
return err

View File

@ -7,7 +7,6 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/system"
"github.com/pkg/errors"
)
@ -18,9 +17,7 @@ func (i *ImageService) LookupImage(name string) (*types.ImageInspect, error) {
if err != nil {
return nil, errors.Wrapf(err, "no such image: %s", name)
}
if !system.IsOSSupported(img.OperatingSystem()) {
return nil, system.ErrNotSupportedOperatingSystem
}
refs := i.referenceStore.References(img.ID().Digest())
repoTags := []string{}
repoDigests := []string{}

View File

@ -285,9 +285,6 @@ func (i *ImageService) SquashImage(id, parent string) (string, error) {
rootFS := image.NewRootFS()
parentImg = &image.Image{RootFS: rootFS}
}
if !system.IsOSSupported(img.OperatingSystem()) {
return "", errors.Wrap(err, system.ErrNotSupportedOperatingSystem.Error())
}
l, err := i.layerStore.Get(img.RootFS.ChainID())
if err != nil {
return "", errors.Wrap(err, "error getting image layer")