Skip to content

Commit 047d58f

Browse files
authored
Merge pull request moby#43187 from thaJeztah/remove_lcow_checks
Remove various leftover LCOW checks
2 parents 81db56f + b36d896 commit 047d58f

File tree

21 files changed

+42
-94
lines changed

21 files changed

+42
-94
lines changed

builder/dockerfile/builder.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/docker/docker/pkg/idtools"
1919
"github.com/docker/docker/pkg/streamformatter"
2020
"github.com/docker/docker/pkg/stringid"
21-
"github.com/docker/docker/pkg/system"
2221
"github.com/moby/buildkit/frontend/dockerfile/instructions"
2322
"github.com/moby/buildkit/frontend/dockerfile/parser"
2423
"github.com/moby/buildkit/frontend/dockerfile/shell"
@@ -319,9 +318,6 @@ func (b *Builder) dispatchDockerfileWithCancellation(parseResult []instructions.
319318
//
320319
// TODO: Remove?
321320
func BuildFromConfig(config *container.Config, changes []string, os string) (*container.Config, error) {
322-
if !system.IsOSSupported(os) {
323-
return nil, errdefs.InvalidParameter(system.ErrNotSupportedOperatingSystem)
324-
}
325321
if len(changes) == 0 {
326322
return config, nil
327323
}

builder/dockerfile/dispatchers.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,27 +246,19 @@ func (d *dispatchRequest) getImageOrStage(name string, platform *specs.Platform)
246246
platform = d.builder.platform
247247
}
248248

249-
// Windows cannot support a container with no base image unless it is LCOW.
249+
// Windows cannot support a container with no base image.
250250
if name == api.NoBaseImageSpecifier {
251-
p := platforms.DefaultSpec()
252-
if platform != nil {
253-
p = *platform
251+
// Windows supports scratch. What is not supported is running containers from it.
252+
if runtime.GOOS == "windows" {
253+
return nil, errors.New("Windows does not support FROM scratch")
254254
}
255-
imageImage := &image.Image{}
256-
imageImage.OS = p.OS
257255

258-
// old windows scratch handling
259256
// TODO: scratch should not have an os. It should be nil image.
260-
// Windows supports scratch. What is not supported is running containers
261-
// from it.
262-
if runtime.GOOS == "windows" {
263-
if platform == nil || platform.OS == "linux" {
264-
return nil, errors.New("Linux containers are not supported on this system")
265-
} else if platform.OS == "windows" {
266-
return nil, errors.New("Windows does not support FROM scratch")
267-
} else {
268-
return nil, errors.Errorf("platform %s is not supported", platforms.Format(p))
269-
}
257+
imageImage := &image.Image{}
258+
if platform != nil {
259+
imageImage.OS = platform.OS
260+
} else {
261+
imageImage.OS = runtime.GOOS
270262
}
271263
return builder.Image(imageImage), nil
272264
}

builder/dockerfile/dispatchers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestFromScratch(t *testing.T) {
117117
err := initializeStage(sb, cmd)
118118

119119
if runtime.GOOS == "windows" {
120-
assert.Check(t, is.Error(err, "Linux containers are not supported on this system"))
120+
assert.Check(t, is.Error(err, "Windows does not support FROM scratch"))
121121
return
122122
}
123123

builder/dockerfile/evaluator.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile"
2121

2222
import (
2323
"reflect"
24-
"runtime"
2524
"strconv"
2625
"strings"
2726

@@ -216,9 +215,6 @@ func (s *dispatchState) beginStage(stageName string, image builder.Image) error
216215
s.stageName = stageName
217216
s.imageID = image.ImageID()
218217
s.operatingSystem = image.OperatingSystem()
219-
if s.operatingSystem == "" { // In case it isn't set
220-
s.operatingSystem = runtime.GOOS
221-
}
222218
if !system.IsOSSupported(s.operatingSystem) {
223219
return system.ErrNotSupportedOperatingSystem
224220
}

daemon/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ func (daemon *Daemon) create(opts createOpts) (retC *container.Container, retErr
123123
return nil, err
124124
}
125125
os = img.OperatingSystem()
126-
imgID = img.ID()
127126
if !system.IsOSSupported(os) {
128-
return nil, errors.New("operating system on which parent image was created is not Windows")
127+
return nil, system.ErrNotSupportedOperatingSystem
129128
}
129+
imgID = img.ID()
130130
} else if isWindows {
131131
os = "linux" // 'scratch' case.
132132
}

daemon/daemon.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
948948
IDMapping: idMapping,
949949
PluginGetter: d.PluginStore,
950950
ExperimentalEnabled: config.Experimental,
951-
OS: runtime.GOOS,
952951
})
953952
if err != nil {
954953
return nil, err

daemon/delete.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (daemon *Daemon) rmLink(container *container.Container, name string) error
7777

7878
// cleanupContainer unregisters a container from the daemon, stops stats
7979
// collection and cleanly removes contents and metadata from the filesystem.
80-
func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemove, removeVolume bool) (err error) {
80+
func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemove, removeVolume bool) error {
8181
if container.IsRunning() {
8282
if !forceRemove {
8383
state := container.StateString()
@@ -92,15 +92,12 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo
9292
return fmt.Errorf("Could not kill running container %s, cannot remove - %v", container.ID, err)
9393
}
9494
}
95-
if !system.IsOSSupported(container.OS) {
96-
return fmt.Errorf("cannot remove %s: %s ", container.ID, system.ErrNotSupportedOperatingSystem)
97-
}
9895

9996
// stop collection of stats for the container regardless
10097
// if stats are currently getting collected.
10198
daemon.statsCollector.StopCollection(container)
10299

103-
if err = daemon.containerStop(container, 3); err != nil {
100+
if err := daemon.containerStop(container, 3); err != nil {
104101
return err
105102
}
106103

@@ -119,8 +116,7 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo
119116
// When container creation fails and `RWLayer` has not been created yet, we
120117
// do not call `ReleaseRWLayer`
121118
if container.RWLayer != nil {
122-
err := daemon.imageService.ReleaseLayer(container.RWLayer, container.OS)
123-
if err != nil {
119+
if err := daemon.imageService.ReleaseLayer(container.RWLayer); err != nil {
124120
err = errors.Wrapf(err, "container %s", container.ID)
125121
container.SetRemovalError(err)
126122
return err
@@ -129,18 +125,18 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo
129125
}
130126

131127
if err := system.EnsureRemoveAll(container.Root); err != nil {
132-
e := errors.Wrapf(err, "unable to remove filesystem for %s", container.ID)
133-
container.SetRemovalError(e)
134-
return e
128+
err = errors.Wrapf(err, "unable to remove filesystem for %s", container.ID)
129+
container.SetRemovalError(err)
130+
return err
135131
}
136132

137133
linkNames := daemon.linkIndex.delete(container)
138134
selinux.ReleaseLabel(container.ProcessLabel)
139135
daemon.idIndex.Delete(container.ID)
140136
daemon.containers.Delete(container.ID)
141137
daemon.containersReplica.Delete(container)
142-
if e := daemon.removeMountPoints(container, removeVolume); e != nil {
143-
logrus.Error(e)
138+
if err := daemon.removeMountPoints(container, removeVolume); err != nil {
139+
logrus.Error(err)
144140
}
145141
for _, name := range linkNames {
146142
daemon.releaseName(name)

daemon/export.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/docker/docker/errdefs"
99
"github.com/docker/docker/pkg/archive"
1010
"github.com/docker/docker/pkg/ioutils"
11-
"github.com/docker/docker/pkg/system"
1211
)
1312

1413
// ContainerExport writes the contents of the container to the given
@@ -47,16 +46,13 @@ func (daemon *Daemon) ContainerExport(name string, out io.Writer) error {
4746
}
4847

4948
func (daemon *Daemon) containerExport(container *container.Container) (arch io.ReadCloser, err error) {
50-
if !system.IsOSSupported(container.OS) {
51-
return nil, fmt.Errorf("cannot export %s: %s ", container.ID, system.ErrNotSupportedOperatingSystem)
52-
}
5349
rwlayer, err := daemon.imageService.GetLayerByID(container.ID)
5450
if err != nil {
5551
return nil, err
5652
}
5753
defer func() {
5854
if err != nil {
59-
daemon.imageService.ReleaseLayer(rwlayer, container.OS)
55+
daemon.imageService.ReleaseLayer(rwlayer)
6056
}
6157
}()
6258

@@ -77,7 +73,7 @@ func (daemon *Daemon) containerExport(container *container.Container) (arch io.R
7773
arch = ioutils.NewReadCloserWrapper(archv, func() error {
7874
err := archv.Close()
7975
rwlayer.Unmount()
80-
daemon.imageService.ReleaseLayer(rwlayer, container.OS)
76+
daemon.imageService.ReleaseLayer(rwlayer)
8177
return err
8278
})
8379
daemon.LogContainerEvent(container, "export")

daemon/images/image_delete.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/docker/docker/errdefs"
1212
"github.com/docker/docker/image"
1313
"github.com/docker/docker/pkg/stringid"
14-
"github.com/docker/docker/pkg/system"
1514
"github.com/pkg/errors"
1615
)
1716

@@ -68,9 +67,6 @@ func (i *ImageService) ImageDelete(imageRef string, force, prune bool) ([]types.
6867
if err != nil {
6968
return nil, err
7069
}
71-
if !system.IsOSSupported(img.OperatingSystem()) {
72-
return nil, errors.Errorf("unable to delete image: %q", system.ErrNotSupportedOperatingSystem)
73-
}
7470

7571
imgID := img.ID()
7672
repoRefs := i.referenceStore.References(imgID.Digest())

daemon/images/image_history.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/docker/distribution/reference"
88
"github.com/docker/docker/api/types/image"
99
"github.com/docker/docker/layer"
10-
"github.com/docker/docker/pkg/system"
1110
)
1211

1312
// ImageHistory returns a slice of ImageHistory structures for the specified image
@@ -32,9 +31,6 @@ func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem,
3231
if len(img.RootFS.DiffIDs) <= layerCounter {
3332
return nil, fmt.Errorf("too many non-empty layers in History section")
3433
}
35-
if !system.IsOSSupported(img.OperatingSystem()) {
36-
return nil, system.ErrNotSupportedOperatingSystem
37-
}
3834
rootFS.Append(img.RootFS.DiffIDs[layerCounter])
3935
l, err := i.layerStore.Get(rootFS.ChainID())
4036
if err != nil {

0 commit comments

Comments
 (0)