Skip to content

Commit

Permalink
updated memory limits by setting ulimits and memlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianco95 committed May 31, 2024
1 parent 76f99e0 commit b6bfcc9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/docker/Create.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,19 @@ func (h *SidecarHandler) CreateHandler(w http.ResponseWriter, r *http.Request) {
//}

memoryLimitsArray := []string{}
uLimitMemoryArray := []string{}
cpuLimitsArray := []string{}

if container.Resources.Limits.Memory().Value() != 0 {
memoryLimitsArray = append(memoryLimitsArray, "--memory", strconv.Itoa(int(container.Resources.Limits.Memory().Value()))+"b")
uLimitMemoryArray = append(uLimitMemoryArray, "--ulimits", "\"memlock="+strconv.Itoa(int(container.Resources.Limits.Memory().Value()))+"\"")
}
if container.Resources.Limits.Cpu().Value() != 0 {
cpuLimitsArray = append(cpuLimitsArray, "--cpus", strconv.FormatFloat(float64(container.Resources.Limits.Cpu().Value()), 'f', -1, 64))
}

cmd = append(cmd, memoryLimitsArray...)
cmd = append(cmd, uLimitMemoryArray...)
cmd = append(cmd, cpuLimitsArray...)

containerCommands := []string{}
Expand Down

0 comments on commit b6bfcc9

Please sign in to comment.