MCPcopy Create free account
hub / github.com/containerd/cgroups / Update

Method Update

cgroup1/memory.go:212–232  ·  view source on GitHub ↗
(path string, resources *specs.LinuxResources)

Source from the content-addressed store, hash-verified

210}
211
212func (m *memoryController) Update(path string, resources *specs.LinuxResources) error {
213 if resources.Memory == nil {
214 return nil
215 }
216 g := func(v *int64) bool {
217 return v != nil && *v > 0
218 }
219 settings := getMemorySettings(resources)
220 if g(resources.Memory.Limit) && g(resources.Memory.Swap) {
221 // if the updated swap value is larger than the current memory limit set the swap changes first
222 // then set the memory limit as swap must always be larger than the current limit
223 current, err := readUint(filepath.Join(m.Path(path), "memory.limit_in_bytes"))
224 if err != nil {
225 return err
226 }
227 if current < uint64(*resources.Memory.Swap) {
228 settings[0], settings[1] = settings[1], settings[0]
229 }
230 }
231 return m.set(path, settings)
232}
233
234func (m *memoryController) Stat(path string, stats *v1.Metrics) error {
235 fMemStat, err := os.Open(filepath.Join(m.Path(path), "memory.stat"))

Callers

nothing calls this directly

Calls 4

PathMethod · 0.95
setMethod · 0.95
getMemorySettingsFunction · 0.85
readUintFunction · 0.85

Tested by

no test coverage detected