MCPcopy Create free account
hub / github.com/containerd/nerdctl / withCustomMemoryResources

Function withCustomMemoryResources

pkg/cmd/container/run_cgroup_linux.go:327–348  ·  view source on GitHub ↗
(memoryOptions customMemoryOptions)

Source from the content-addressed store, hash-verified

325}
326
327func withCustomMemoryResources(memoryOptions customMemoryOptions) oci.SpecOpts {
328 return func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
329 if s.Linux != nil {
330 if s.Linux.Resources == nil {
331 s.Linux.Resources = &specs.LinuxResources{}
332 }
333 if s.Linux.Resources.Memory == nil {
334 s.Linux.Resources.Memory = &specs.LinuxMemory{}
335 }
336 if memoryOptions.disableOOMKiller != nil {
337 s.Linux.Resources.Memory.DisableOOMKiller = memoryOptions.disableOOMKiller
338 }
339 if memoryOptions.MemorySwappiness != nil {
340 s.Linux.Resources.Memory.Swappiness = memoryOptions.MemorySwappiness
341 }
342 if memoryOptions.MemoryReservation != nil {
343 s.Linux.Resources.Memory.Reservation = memoryOptions.MemoryReservation
344 }
345 }
346 return nil
347 }
348}

Callers 1

generateCgroupOptsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…