refactor(#2754): make the container weights Option, not a 0 sentinel
Encoding "not configured" as weight 0 worked (the writer omitted the line) but the type lied: 0 is not a legal cgroup v2 weight, and every reader had to know the sentinel. Use Option<u32> end to end instead — wire type, priv_client, HiveEnv, drop-in writer — so "unset" is a state of the type rather than a magic value. The nix options become nullOr, keeping their default of 80; null now expresses "leave the setting out of the drop-in entirely" declaratively, which is the useful shape on a host whose IO scheduler ignores io.weight anyway. Backward compat is unchanged: the fields stay #[serde(default)], so a request from an older hive-c0re deserialises to None and reproduces the pre-weights drop-in byte for byte. The test that pins that now passes None instead of 0.
This commit is contained in:
parent
e407fa93df
commit
5d3f2af75e
7 changed files with 59 additions and 51 deletions
|
|
@ -343,15 +343,17 @@ pub enum PrivRequest {
|
|||
container: String,
|
||||
memory_max: String,
|
||||
cpu_quota: String,
|
||||
/// cgroup v2 `cpu.weight`, 1..=10000. `#[serde(default)]` so a
|
||||
/// hive-priv built before this field still deserialises new
|
||||
/// requests; 0 is treated as "omit the line" by the writer.
|
||||
/// cgroup v2 `cpu.weight`, 1..=10000. `None` means "not
|
||||
/// configured" — the writer omits the line entirely, leaving the
|
||||
/// kernel default. `#[serde(default)]` so a request from a
|
||||
/// hive-c0re built before this field existed deserialises to
|
||||
/// `None` and reproduces the pre-weights drop-in.
|
||||
#[serde(default)]
|
||||
cpu_weight: u32,
|
||||
/// cgroup v2 `io.weight`, 1..=10000. Same default/omit rule as
|
||||
cpu_weight: Option<u32>,
|
||||
/// cgroup v2 `io.weight`, 1..=10000. Same `None` = omit rule as
|
||||
/// `cpu_weight`.
|
||||
#[serde(default)]
|
||||
io_weight: u32,
|
||||
io_weight: Option<u32>,
|
||||
},
|
||||
|
||||
/// Remove `/run/systemd/system/container@<container>.service.d/` if present.
|
||||
|
|
|
|||
Loading…
Reference in a new issue