Skip to content

Commit

Permalink
Merge pull request moby#40766 from thaJeztah/lcow_build_tag
Browse files Browse the repository at this point in the history
LCOW: add "no_lcow" build tag to allow disabling lcow
  • Loading branch information
cpuguy83 authored Apr 20, 2020
2 parents 55e6d7d + 0d3b400 commit 71626b7
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 50 deletions.
12 changes: 0 additions & 12 deletions pkg/system/init_unix.go

This file was deleted.

11 changes: 0 additions & 11 deletions pkg/system/init_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,15 @@ package system // import "github.com/docker/docker/pkg/system"
import (
"os"

"github.com/Microsoft/hcsshim/osversion"
"github.com/sirupsen/logrus"
)

var (
// lcowSupported determines if Linux Containers on Windows are supported.
lcowSupported = false

// containerdRuntimeSupported determines if ContainerD should be the runtime.
// As of March 2019, this is an experimental feature.
containerdRuntimeSupported = false
)

// InitLCOW sets whether LCOW is supported or not. Requires RS5+
func InitLCOW(experimental bool) {
if experimental && osversion.Build() >= osversion.RS5 {
lcowSupported = true
}
}

// InitContainerdRuntime sets whether to use ContainerD for runtime
// on Windows. This is an experimental feature still in development, and
// also requires an environment variable to be set (so as not to turn the
Expand Down
42 changes: 29 additions & 13 deletions pkg/system/lcow.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
// +build windows,!no_lcow

package system // import "github.com/docker/docker/pkg/system"

import (
"runtime"
"strings"

"github.com/Microsoft/hcsshim/osversion"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)

// IsOSSupported determines if an operating system is supported by the host
func IsOSSupported(os string) bool {
if strings.EqualFold(runtime.GOOS, os) {
return true
}
if LCOWSupported() && strings.EqualFold(os, "linux") {
return true
var (
// lcowSupported determines if Linux Containers on Windows are supported.
lcowSupported = false
)

// InitLCOW sets whether LCOW is supported or not. Requires RS5+
func InitLCOW(experimental bool) {
if experimental && osversion.Build() >= osversion.RS5 {
lcowSupported = true
}
return false
}

func LCOWSupported() bool {
return lcowSupported
}

// ValidatePlatform determines if a platform structure is valid.
// TODO This is a temporary windows-only function, should be replaced by
// comparison of worker capabilities
func ValidatePlatform(platform specs.Platform) error {
if runtime.GOOS == "windows" {
if !(platform.OS == runtime.GOOS || (LCOWSupported() && platform.OS == "linux")) {
return errors.Errorf("unsupported os %s", platform.OS)
}
if !IsOSSupported(platform.OS) {
return errors.Errorf("unsupported os %s", platform.OS)
}
return nil
}

// IsOSSupported determines if an operating system is supported by the host
func IsOSSupported(os string) bool {
if strings.EqualFold("windows", os) {
return true
}
if LCOWSupported() && strings.EqualFold(os, "linux") {
return true
}
return false
}
8 changes: 0 additions & 8 deletions pkg/system/lcow_unix.go

This file was deleted.

28 changes: 28 additions & 0 deletions pkg/system/lcow_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// +build !windows windows,no_lcow

package system // import "github.com/docker/docker/pkg/system"
import (
"runtime"
"strings"

specs "github.com/opencontainers/image-spec/specs-go/v1"
)

// InitLCOW does nothing since LCOW is a windows only feature
func InitLCOW(_ bool) {}

// LCOWSupported returns true if Linux containers on Windows are supported.
func LCOWSupported() bool {
return false
}

// ValidatePlatform determines if a platform structure is valid. This function
// is used for LCOW, and is a no-op on non-windows platforms.
func ValidatePlatform(_ specs.Platform) error {
return nil
}

// IsOSSupported determines if an operating system is supported by the host.
func IsOSSupported(os string) bool {
return strings.EqualFold(runtime.GOOS, os)
}
6 changes: 0 additions & 6 deletions pkg/system/lcow_windows.go

This file was deleted.

6 changes: 6 additions & 0 deletions project/PACKAGERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ NOTE: if you need to set more than one build tag, space separate them:
export DOCKER_BUILDTAGS='apparmor selinux exclude_graphdriver_aufs'
```

### LCOW (Linux Containers On Windows)

LCOW is an experimental feature on Windows, and requires the daemon to run with
experimental features enabled. Use the `no_lcow` build tag to disable the LCOW
feature at compile time,

### Static Daemon

If it is feasible within the constraints of your distribution, you should
Expand Down

0 comments on commit 71626b7

Please sign in to comment.