Merge pull request #39005 from brendandburns/windows

Automatic merge from submit-queue (batch tested with PRs 38212, 38792, 39641, 36390, 39005)

Set MemorySwap to zero on Windows

Fixes https://github.com/kubernetes/kubernetes/issues/39003

@dchen1107 @michmike @kubernetes/sig-node-misc
This commit is contained in:
Kubernetes Submit Queue 2017-01-10 19:48:16 -08:00 committed by GitHub
commit d3c0914a14
6 changed files with 39 additions and 8 deletions

View File

@ -133,7 +133,7 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeapi
if rOpts != nil {
hc.Resources = dockercontainer.Resources{
Memory: rOpts.GetMemoryLimitInBytes(),
MemorySwap: -1,
MemorySwap: dockertools.DefaultMemorySwap(),
CPUShares: rOpts.GetCpuShares(),
CPUQuota: rOpts.GetCpuQuota(),
CPUPeriod: rOpts.GetCpuPeriod(),

View File

@ -26,6 +26,7 @@ import (
runtimeapi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/qos"
"k8s.io/kubernetes/pkg/kubelet/types"
)
@ -373,7 +374,7 @@ func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
func setSandboxResources(hc *dockercontainer.HostConfig) {
hc.Resources = dockercontainer.Resources{
MemorySwap: -1,
MemorySwap: dockertools.DefaultMemorySwap(),
CPUShares: defaultSandboxCPUshares,
// Use docker's default cpu quota/period.
}

View File

@ -28,7 +28,6 @@ import (
"os/exec"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
@ -710,11 +709,7 @@ func (dm *DockerManager) runContainer(
SecurityOpt: fmtSecurityOpts,
}
// There is no /etc/resolv.conf in Windows, DNS and DNSSearch options would have to be passed to Docker runtime instead
if runtime.GOOS == "windows" {
hc.DNS = opts.DNS
hc.DNSSearch = opts.DNSSearch
}
updateHostConfig(hc)
// Set sysctls if requested
if container.Name == PodInfraContainerName {

View File

@ -20,9 +20,20 @@ package dockertools
import (
dockertypes "github.com/docker/engine-api/types"
dockercontainer "github.com/docker/engine-api/types/container"
"k8s.io/kubernetes/pkg/api/v1"
)
// These two functions are OS specific (for now at least)
func updateHostConfig(config *dockercontainer.HostConfig) {
// no-op, there is a windows implementation that is different.
}
func DefaultMemorySwap() int64 {
return -1
}
func getContainerIP(container *dockertypes.ContainerJSON) string {
result := ""
if container.NetworkSettings != nil {

View File

@ -24,6 +24,14 @@ import (
dockertypes "github.com/docker/engine-api/types"
)
// These two functions are OS specific (for now at least)
func updateHostConfig(config *dockercontainer.HostConfig) {
}
func DefaultMemorySwap() int64 {
return -1
}
func getContainerIP(container *dockertypes.ContainerJSON) string {
return ""
}

View File

@ -24,8 +24,24 @@ import (
"k8s.io/kubernetes/pkg/api/v1"
dockertypes "github.com/docker/engine-api/types"
dockercontainer "github.com/docker/engine-api/types/container"
)
// These two functions are OS specific (for now at least)
func updateHostConfig(config *dockercontainer.HostConfig) {
// There is no /etc/resolv.conf in Windows, DNS and DNSSearch options would have to be passed to Docker runtime instead
hc.DNS = opts.DNS
hc.DNSSearch = opts.DNSSearch
// MemorySwap == -1 is not currently supported in Docker 1.14 on Windows
// https://github.com/docker/docker/blob/master/daemon/daemon_windows.go#L175
hc.Resources.MemorySwap = 0
}
func DefaultMemorySwap() int64 {
return 0
}
func getContainerIP(container *dockertypes.ContainerJSON) string {
if container.NetworkSettings != nil {
for _, network := range container.NetworkSettings.Networks {