From c90580cec4bbe2c6715a1197b2bd5bd88ab83ac7 Mon Sep 17 00:00:00 2001 From: CMGS Date: Tue, 23 Mar 2021 16:42:05 +0800 Subject: [PATCH] support ulimit for docker engine #362 --- Makefile | 3 ++- engine/docker/container.go | 21 +++++++++++++-------- rpc/gen/core.proto | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 6a307632c..23d30eb76 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,8 @@ unit-test: ./resources/storage/... \ ./resources/volume/... \ ./resources/cpumem/... \ - ./wal/... + ./wal/. \ + ./wal/kv/. lint: golangci-lint run diff --git a/engine/docker/container.go b/engine/docker/container.go index ab7992cb2..909342480 100644 --- a/engine/docker/container.go +++ b/engine/docker/container.go @@ -44,6 +44,7 @@ type rawArgs struct { StorageOpt map[string]string `json:"storage_opt"` CapAdd []string `json:"cap_add"` CapDrop []string `json:"cap_drop"` + Ulimits []*units.Ulimit `json:"ulimits"` } // VirtualizationCreate create a workload @@ -124,21 +125,25 @@ func (e *Engine) VirtualizationCreate(ctx context.Context, opts *enginetypes.Vir Tty: opts.Stdin, } + rArgs := &rawArgs{StorageOpt: map[string]string{}} + if len(opts.RawArgs) > 0 { + if err := json.Unmarshal(opts.RawArgs, rArgs); err != nil { + return r, err + } + } resource := makeResourceSetting(opts.Quota, opts.Memory, opts.CPU, opts.NUMANode) // set ulimits - resource.Ulimits = []*units.Ulimit{ - {Name: "nofile", Soft: 65535, Hard: 65535}, + if len(rArgs.Ulimits) == 0 { + resource.Ulimits = []*units.Ulimit{ + {Name: "nofile", Soft: 65535, Hard: 65535}, + } + } else { + resource.Ulimits = rArgs.Ulimits } if networkMode.IsHost() { opts.DNS = []string{} opts.Sysctl = map[string]string{} } - rArgs := &rawArgs{StorageOpt: map[string]string{}} - if len(opts.RawArgs) > 0 { - if err := json.Unmarshal(opts.RawArgs, rArgs); err != nil { - return r, err - } - } if opts.Storage > 0 { volumeTotal := int64(0) for _, v := range opts.Volumes { diff --git a/rpc/gen/core.proto b/rpc/gen/core.proto index efd7f4723..dcfd0fa6b 100644 --- a/rpc/gen/core.proto +++ b/rpc/gen/core.proto @@ -449,7 +449,7 @@ message DeployOptions { map networks = 11; string user = 13; bool debug = 14; - bool openStdin = 15; + bool open_stdin = 15; map labels = 16; // map nodelabels = 17; DEPRECATED Strategy deploy_strategy = 18;