-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Microsoft/hcsshim constants and deprecate pkg/system.GetOsVersion() #39100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"strings" | ||
|
||
"github.com/Microsoft/hcsshim" | ||
"github.com/Microsoft/hcsshim/osversion" | ||
"github.com/docker/docker/api/types" | ||
containertypes "github.com/docker/docker/api/types/container" | ||
"github.com/docker/docker/container" | ||
|
@@ -126,8 +127,7 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, isHyp | |
return warnings, fmt.Errorf("range of CPUs is from 0.01 to %d.00, as there are only %d CPUs available", sysinfo.NumCPU(), sysinfo.NumCPU()) | ||
} | ||
|
||
osv := system.GetOSVersion() | ||
if resources.NanoCPUs > 0 && isHyperv && osv.Build < 16175 { | ||
if resources.NanoCPUs > 0 && isHyperv && osversion.Build() < osversion.RS3 { | ||
leftoverNanoCPUs := resources.NanoCPUs % 1e9 | ||
if leftoverNanoCPUs != 0 && resources.NanoCPUs > 1e9 { | ||
resources.NanoCPUs = ((resources.NanoCPUs + 1e9/2) / 1e9) * 1e9 | ||
|
@@ -196,14 +196,13 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. | |
if hostConfig == nil { | ||
return nil, nil | ||
} | ||
osv := system.GetOSVersion() | ||
hyperv := daemon.runAsHyperVContainer(hostConfig) | ||
|
||
// On RS5, we allow (but don't strictly support) process isolation on Client SKUs. | ||
// Prior to RS5, we don't allow process isolation on Client SKUs. | ||
// @engine maintainers. This block should not be removed. It partially enforces licensing | ||
// restrictions on Windows. Ping Microsoft folks if there are concerns or PRs to change this. | ||
if !hyperv && system.IsWindowsClient() && osv.Build < 17763 { | ||
if !hyperv && system.IsWindowsClient() && osversion.Build() < osversion.RS5 { | ||
return warnings, fmt.Errorf("Windows client operating systems earlier than version 1809 can only run Hyper-V containers") | ||
} | ||
|
||
|
@@ -225,7 +224,7 @@ func checkSystem() error { | |
if osv.MajorVersion < 10 { | ||
thaJeztah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return fmt.Errorf("This version of Windows does not support the docker daemon") | ||
} | ||
if osv.Build < 14393 { | ||
if osversion.Build() < osversion.RS1 { | ||
return fmt.Errorf("The docker daemon requires build 14393 or later of Windows Server 2016 or Windows 10") | ||
} | ||
|
||
|
@@ -425,26 +424,15 @@ func initBridgeDriver(controller libnetwork.NetworkController, config *config.Co | |
winlibnetwork.NetworkName: runconfig.DefaultDaemonNetworkMode().NetworkName(), | ||
} | ||
|
||
var ipamOption libnetwork.NetworkOption | ||
var subnetPrefix string | ||
|
||
subnetPrefix := defaultNetworkSpace | ||
if config.BridgeConfig.FixedCIDR != "" { | ||
subnetPrefix = config.BridgeConfig.FixedCIDR | ||
} else { | ||
// TP5 doesn't support properly detecting subnet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this as TP5 is really obsolete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any idea why the original code scoped the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Things were still in development on the Windows side, so I think 14360 was a build where new features became available; that's been a long time back, so I'd have to check git history if there's any info about that |
||
osv := system.GetOSVersion() | ||
if osv.Build < 14360 { | ||
subnetPrefix = defaultNetworkSpace | ||
} | ||
} | ||
|
||
if subnetPrefix != "" { | ||
ipamV4Conf := libnetwork.IpamConf{} | ||
ipamV4Conf.PreferredPool = subnetPrefix | ||
v4Conf := []*libnetwork.IpamConf{&ipamV4Conf} | ||
v6Conf := []*libnetwork.IpamConf{} | ||
ipamOption = libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil) | ||
} | ||
ipamV4Conf := libnetwork.IpamConf{PreferredPool: subnetPrefix} | ||
v4Conf := []*libnetwork.IpamConf{&ipamV4Conf} | ||
v6Conf := []*libnetwork.IpamConf{} | ||
ipamOption := libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil) | ||
|
||
_, err := controller.NewNetwork(string(runconfig.DefaultDaemonNetworkMode()), runconfig.DefaultDaemonNetworkMode().NetworkName(), "", | ||
libnetwork.NetworkOptionGeneric(options.Generic{ | ||
|
@@ -602,7 +590,6 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) { | |
// daemon to run in. This is only applicable on Windows | ||
func (daemon *Daemon) setDefaultIsolation() error { | ||
daemon.defaultIsolation = containertypes.Isolation("process") | ||
osv := system.GetOSVersion() | ||
|
||
// On client SKUs, default to Hyper-V. @engine maintainers. This | ||
// should not be removed. Ping Microsoft folks is there are PRs to | ||
|
@@ -626,7 +613,7 @@ func (daemon *Daemon) setDefaultIsolation() error { | |
daemon.defaultIsolation = containertypes.Isolation("hyperv") | ||
} | ||
if containertypes.Isolation(val).IsProcess() { | ||
if system.IsWindowsClient() && osv.Build < 17763 { | ||
if system.IsWindowsClient() && osversion.Build() < osversion.RS5 { | ||
// On RS5, we allow (but don't strictly support) process isolation on Client SKUs. | ||
// @engine maintainers. This block should not be removed. It partially enforces licensing | ||
// restrictions on Windows. Ping Microsoft folks if there are concerns or PRs to change this. | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -24,14 +24,14 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/Microsoft/go-winio/backuptar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/Microsoft/go-winio/vhd" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/Microsoft/hcsshim" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/Microsoft/hcsshim/osversion" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/daemon/graphdriver" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/pkg/archive" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/pkg/containerfs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/pkg/idtools" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/pkg/ioutils" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/pkg/longpath" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/pkg/reexec" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/docker/docker/pkg/system" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
units "github.com/docker/go-units" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/pkg/errors" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/sirupsen/logrus" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -272,7 +272,6 @@ func (d *Driver) Remove(id string) error { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// it is a transient error. Retry until it succeeds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var computeSystems []hcsshim.ContainerProperties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
retryCount := 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
osv := system.GetOSVersion() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Get and terminate any template VMs that are currently using the layer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Note: It is unfortunate that we end up in the graphdrivers Remove() call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -294,8 +293,10 @@ func (d *Driver) Remove(id string) error { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// not required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
computeSystems, err = hcsshim.GetContainers(hcsshim.ComputeSystemQuery{}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (osv.Build < 15139) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 15139 is somewhere between RS2 and RS3; from the context, it looks like the loop must be skipped on RS3 and up; I change it to an early return to make it slightly more readable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, no I think you've changed the logic incorrectly here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh; why didn't I see this comment; I'll have to check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I think my logic is correct, but @lowenna @kolyshkin please double check; (Simplified code, and replaced Old situationif err != nil {
if (ver < RS3) && ((err ==InvalidState) || (err == AccessIsDenied)) {
// retry
}
return err
}
New situation:if err != nil {
if ver >= RS3 {
// no retry, return error
}
if (err == InvalidState) || (err == AccessIsDenied) {
// retry
}
return err
}
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new logic looks correct to me. By the way, I found an obsoleted TODO comment just above this. I think the part of it needs to be removed, this one:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
((err == hcsshim.ErrVmcomputeOperationInvalidState) || (err == hcsshim.ErrVmcomputeOperationAccessIsDenied)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if osversion.Build() >= osversion.RS3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (err == hcsshim.ErrVmcomputeOperationInvalidState) || (err == hcsshim.ErrVmcomputeOperationAccessIsDenied) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if retryCount >= 500 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"strings" | ||
"testing" | ||
|
||
"github.com/Microsoft/hcsshim/osversion" | ||
"github.com/docker/docker/api/types" | ||
"github.com/docker/docker/api/types/filters" | ||
"github.com/docker/docker/client" | ||
|
@@ -59,10 +60,12 @@ func (s *DockerSuite) TestAPIImagesFilter(c *testing.T) { | |
|
||
func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *testing.T) { | ||
if runtime.GOOS == "windows" { | ||
// Note we parse kernel.GetKernelVersion rather than osversion.Build() | ||
// as test binaries aren't manifested, so would otherwise report build 9200. | ||
v, err := kernel.GetKernelVersion() | ||
assert.NilError(c, err) | ||
build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0]) | ||
if build <= 16299 { | ||
buildNumber, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. renaming these as they overlap with the |
||
if buildNumber <= osversion.RS3 { | ||
c.Skip("Temporarily disabled on RS3 and older because they are too slow. See #39909") | ||
} | ||
} | ||
|
@@ -139,10 +142,12 @@ func (s *DockerSuite) TestAPIImagesHistory(c *testing.T) { | |
|
||
func (s *DockerSuite) TestAPIImagesImportBadSrc(c *testing.T) { | ||
if runtime.GOOS == "windows" { | ||
// Note we parse kernel.GetKernelVersion rather than osversion.Build() | ||
// as test binaries aren't manifested, so would otherwise report build 9200. | ||
v, err := kernel.GetKernelVersion() | ||
assert.NilError(c, err) | ||
build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0]) | ||
if build == 16299 { | ||
buildNumber, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0]) | ||
if buildNumber == osversion.RS3 { | ||
c.Skip("Temporarily disabled on RS3 builds") | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/Microsoft/hcsshim/osversion" | ||
"github.com/docker/docker/client" | ||
"github.com/docker/docker/integration-cli/cli" | ||
"github.com/docker/docker/integration-cli/cli/build" | ||
|
@@ -1880,7 +1881,7 @@ func (s *DockerSuite) TestRunBindMounts(c *testing.T) { | |
|
||
if testEnv.OSType == "windows" { | ||
// Disabled prior to RS5 due to how volumes are mapped | ||
testRequires(c, DaemonIsWindowsAtLeastBuild(17763)) | ||
testRequires(c, DaemonIsWindowsAtLeastBuild(osversion.RS5)) | ||
} | ||
|
||
prefix, _ := getPrefixAndSlashFromDaemonPlatform() | ||
|
@@ -3915,16 +3916,16 @@ func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *testing.T) { | |
} | ||
|
||
func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) { | ||
// TODO @msabansal - https://github.com/moby/moby/issues/35023. Duplicate | ||
// port mappings are not errored out on RS3 builds. Temporarily disabling | ||
// this test pending further investigation. Note we parse kernel.GetKernelVersion | ||
// rather than system.GetOSVersion as test binaries aren't manifested, so would | ||
// otherwise report build 9200. | ||
if runtime.GOOS == "windows" { | ||
// TODO @msabansal - https://github.com/moby/moby/issues/35023. Duplicate | ||
// port mappings are not errored out on RS3 builds. Temporarily disabling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is no longer needed, and will be removed in #39845 |
||
// this test pending further investigation. Note we parse kernel.GetKernelVersion | ||
// rather than osversion.Build() as test binaries aren't manifested, so would | ||
// otherwise report build 9200. | ||
v, err := kernel.GetKernelVersion() | ||
assert.NilError(c, err) | ||
build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0]) | ||
if build == 16299 { | ||
buildNumber, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0]) | ||
if buildNumber == osversion.RS3 { | ||
c.Skip("Temporarily disabled on RS3 builds") | ||
} | ||
} | ||
|
@@ -4532,7 +4533,7 @@ func (s *DockerSuite) TestRunAddDeviceCgroupRule(c *testing.T) { | |
|
||
// Verifies that running as local system is operating correctly on Windows | ||
func (s *DockerSuite) TestWindowsRunAsSystem(c *testing.T) { | ||
testRequires(c, DaemonIsWindowsAtLeastBuild(15000)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is somewhere between RS1 and RS2, so I took RS3 |
||
testRequires(c, DaemonIsWindowsAtLeastBuild(osversion.RS3)) | ||
out, _ := dockerCmd(c, "run", "--net=none", `--user=nt authority\system`, "--hostname=XYZZY", minimalBaseImage(), "cmd", "/c", `@echo %USERNAME%`) | ||
assert.Equal(c, strings.TrimSpace(out), "XYZZY$") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/Microsoft/hcsshim/osversion" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arf. think my IDE had goimports disabled; let me check my config |
||
"github.com/docker/docker/integration-cli/cli" | ||
"github.com/docker/docker/pkg/parsers/kernel" | ||
"gotest.tools/assert" | ||
|
@@ -196,7 +198,7 @@ func (s *DockerSuite) TestStartReturnCorrectExitCode(c *testing.T) { | |
v, err := kernel.GetKernelVersion() | ||
assert.NilError(c, err) | ||
build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0]) | ||
if build < 16299 { | ||
if build < osversion.RS3 { | ||
c.Skip("FLAKY on Windows RS1, see #38521") | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version was somewhere between "RS2" and "RS3", so I picked
< RS3