Skip to content

Commit

Permalink
support ulimit for docker engine #362
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Mar 23, 2021
1 parent 41c527b commit c90580c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ unit-test:
./resources/storage/... \
./resources/volume/... \
./resources/cpumem/... \
./wal/...
./wal/. \
./wal/kv/.

lint:
golangci-lint run
21 changes: 13 additions & 8 deletions engine/docker/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion rpc/gen/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ message DeployOptions {
map<string, string> networks = 11;
string user = 13;
bool debug = 14;
bool openStdin = 15;
bool open_stdin = 15;
map<string, string> labels = 16;
// map<string, string> nodelabels = 17; DEPRECATED
Strategy deploy_strategy = 18;
Expand Down

0 comments on commit c90580c

Please sign in to comment.