Ver código fonte

Skip KernelMemoryTCP if version is less than 1.40

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Yong Tang 6 anos atrás
pai
commit
ee74cd777a

+ 6 - 0
api/server/router/container/container_routes.go

@@ -475,6 +475,12 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
 		}
 	}
 
+	// When using API 1.39 and under, KernelMemoryTCP should be ignored because it
+	// was added in API 1.40.
+	if hostConfig != nil && versions.LessThan(version, "1.40") {
+		hostConfig.KernelMemoryTCP = 0
+	}
+
 	ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{
 		Name:             name,
 		Config:           config,

+ 2 - 0
integration/container/run_linux_test.go

@@ -8,6 +8,7 @@ import (
 	"time"
 
 	containertypes "github.com/docker/docker/api/types/container"
+	"github.com/docker/docker/api/types/versions"
 	"github.com/docker/docker/integration/internal/container"
 	"github.com/docker/docker/internal/test/request"
 	"gotest.tools/assert"
@@ -18,6 +19,7 @@ import (
 
 func TestKernelTCPMemory(t *testing.T) {
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
+	skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.40"), "skip test from new feature")
 	skip.If(t, !testEnv.DaemonInfo.KernelMemoryTCP)
 
 	defer setupTest(t)()