File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -206,29 +206,31 @@ package struct Cgroup2Manager: Sendable {
206206 ] )
207207
208208 if let memory = resources. memory, let limit = memory. limit {
209+ // The OCI spec defines -1 as unlimited; cgroup v2 expects "max".
210+ let value = limit < 0 ? " max " : String ( limit)
209211 try Self . writeValue (
210212 path: self . path,
211- value: String ( limit ) ,
213+ value: value ,
212214 fileName: " memory.max "
213215 )
214216 }
215217
216- if let cpu = resources. cpu {
217- if let quota = cpu. quota, let period = cpu. period {
218- // cpu.max format is "quota period"
219- let value = " \( quota) \( period) "
220- try Self . writeValue (
221- path: self . path,
222- value: value,
223- fileName: " cpu.max "
224- )
225- }
218+ if let cpu = resources. cpu, let quota = cpu. quota, let period = cpu. period {
219+ // cpu.max format is "quota period"
220+ let value = " \( quota) \( period) "
221+ try Self . writeValue (
222+ path: self . path,
223+ value: value,
224+ fileName: " cpu.max "
225+ )
226226 }
227227
228228 if let pids = resources. pids {
229+ // The OCI spec defines -1 as unlimited; cgroup v2 expects "max".
230+ let value = pids. limit < 0 ? " max " : String ( pids. limit)
229231 try Self . writeValue (
230232 path: self . path,
231- value: String ( pids . limit ) ,
233+ value: value ,
232234 fileName: " pids.max "
233235 )
234236 }
You can’t perform that action at this time.
0 commit comments