Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 5ec0ef8

Browse files
committed
move vm.overcommit_memory related code to hyperstart
Signed-off-by: Lai Jiangshan <[email protected]>
1 parent 3833afa commit 5ec0ef8

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

agent/hyperstart.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,16 @@ func (h *jsonBasedHyperstart) convertContainer(container string, user *runvapi.U
831831
if shareDir != "" && strings.HasPrefix(oci.Root.Path, shareDir) {
832832

833833
}
834+
835+
// And "vm.overcommit_memory" sysctl. TODO: Don't modify it inplace
836+
// TODO "vm.overcommit_memory" is sanbox level systl, find a way to handle it for kata-agent
837+
if oci.Linux.Sysctl == nil {
838+
oci.Linux.Sysctl = map[string]string{}
839+
}
840+
if _, ok := oci.Linux.Sysctl["vm.overcommit_memory"]; !ok {
841+
oci.Linux.Sysctl["vm.overcommit_memory"] = "1"
842+
}
843+
834844
rtContainer := &hyperstartapi.Container{ // runtime Container
835845
Id: container,
836846
Process: hyperstartapi.ProcessFromOci("init", oci.Process),

api/helpers.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ func ContainerDescriptionFromOCF(id string, s *ocispecs.Spec) *ContainerDescript
2929
OciSpec: *s,
3030
}
3131

32-
if container.OciSpec.Linux.Sysctl == nil {
33-
container.OciSpec.Linux.Sysctl = map[string]string{}
34-
}
35-
if _, ok := container.OciSpec.Linux.Sysctl["vm.overcommit_memory"]; !ok {
36-
container.OciSpec.Linux.Sysctl["vm.overcommit_memory"] = "1"
37-
}
38-
3932
// the mounts need to be filtered and add it back after ContainerDescriptionFromOCF()
4033
// virtual mounts are added back here.
4134
container.OciSpec.Mounts = []ocispecs.Mount{}

0 commit comments

Comments
 (0)