(path string, resources *specs.LinuxResources)
| 210 | } |
| 211 | |
| 212 | func (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 | |
| 234 | func (m *memoryController) Stat(path string, stats *v1.Metrics) error { |
| 235 | fMemStat, err := os.Open(filepath.Join(m.Path(path), "memory.stat")) |
nothing calls this directly
no test coverage detected