Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit ae8fc2f

Browse files
committed
Merge pull request #640 from estesp/nsinit-memory-swappiness
Fix nsinit to configure default cgroup entry for MemorySwappiness
2 parents 107b7ed + e1128da commit ae8fc2f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

nsinit/config.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var createFlags = []cli.Flag{
2424
cli.IntFlag{Name: "cpushares", Usage: "set the cpushares for the container"},
2525
cli.IntFlag{Name: "memory-limit", Usage: "set the memory limit for the container"},
2626
cli.IntFlag{Name: "memory-swap", Usage: "set the memory swap limit for the container"},
27+
cli.IntFlag{Name: "memory-swappiness", Usage: "set the memory swappiness value (0-100 inclusive) for the container"},
2728
cli.IntFlag{Name: "parent-death-signal", Usage: "set the signal that will be delivered to the process in case the parent dies"},
2829
cli.IntFlag{Name: "userns-root-uid", Usage: "set the user namespace root uid"},
2930
cli.IntFlag{Name: "veth-mtu", Usage: "veth mtu"},
@@ -87,6 +88,7 @@ func modify(config *configs.Config, context *cli.Context) {
8788
config.Cgroups.CpuShares = int64(context.Int("cpushares"))
8889
config.Cgroups.Memory = int64(context.Int("memory-limit"))
8990
config.Cgroups.MemorySwap = int64(context.Int("memory-swap"))
91+
config.Cgroups.MemorySwappiness = int64(context.Int("memory-swappiness"))
9092
config.AppArmorProfile = context.String("apparmor-profile")
9193
config.ProcessLabel = context.String("process-label")
9294
config.MountLabel = context.String("mount-label")
@@ -263,10 +265,11 @@ func getTemplate() *configs.Config {
263265
{Type: configs.NEWNET},
264266
}),
265267
Cgroups: &configs.Cgroup{
266-
Name: filepath.Base(cwd),
267-
Parent: "nsinit",
268-
AllowAllDevices: false,
269-
AllowedDevices: configs.DefaultAllowedDevices,
268+
Name: filepath.Base(cwd),
269+
Parent: "nsinit",
270+
AllowAllDevices: false,
271+
AllowedDevices: configs.DefaultAllowedDevices,
272+
MemorySwappiness: -1,
270273
},
271274
Devices: configs.DefaultAutoCreatedDevices,
272275
MaskPaths: []string{

0 commit comments

Comments
 (0)