agents: read every MemoryMax= size systemd enforces
`parse_bytes` knew only K/M/G/T, in either case. A size with the bare `B` unit (`1048576B`), which `validate_memory_max` stores and systemd enforces, became `infinity` in the agent's cap file: the cgroup was capped while the agent was told there was no cap. It now takes exactly the single-term forms systemd's `parse_size` does: no suffix, `B`, or K/M/G/T/P/E, case-sensitive. Lowercase units and `4GB`, which systemd refuses and so leaves the unit uncapped, read as `infinity` too. A test runs every suffix form the validator accepts through it and checks the stored value parses to the right byte count. Part of #5081 (slice S0-2).
This commit is contained in:
parent
eaca3c4eb3
commit
fb5eb9edc1
2 changed files with 61 additions and 14 deletions
|
|
@ -947,6 +947,8 @@ mod tests {
|
|||
fn a_cap_is_read_the_way_systemd_reads_memory_max() {
|
||||
for (memory_max, cap) in [
|
||||
("4G", "4294967296"),
|
||||
("1048576B", "1048576"),
|
||||
("3P", "3377699720527872"),
|
||||
("infinity", "infinity"),
|
||||
("50%", "8192004096"),
|
||||
("33.33%", "5460787200"),
|
||||
|
|
@ -954,6 +956,8 @@ mod tests {
|
|||
("100%", "16384012288"),
|
||||
// systemd ignores these and the unit runs uncapped.
|
||||
("0", "infinity"),
|
||||
("4g", "infinity"),
|
||||
("4GB", "infinity"),
|
||||
("0%", "infinity"),
|
||||
("150%", "infinity"),
|
||||
("12.345%", "infinity"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue