Skip to content

Commit

Permalink
MetalOS compatibility
Browse files Browse the repository at this point in the history
Summary:
Make `fb-oomd` and `fb-oomd-cfgen` MetalOS compatible:

- Generate `oomd2.json` file in the /etc directory in case of MetalOS mode
- Override cgroups slice with `hostcritical.slice`
- Set `/run/oomd` as SystemdRuntime directory
- Create `/run/oomd/dropin` before service starts
- Enable basic health-check using `/metalols/bin/oomd -d` which connects to running `oomd` over /run/oomd/oomd.socket and dumps some stats.
- Set `ProtectControlGroups` to `False`.

**Follow up:**

Figure out what to do with the `fb_cgroups` settings:

```
# cat /etc/systemd/system/fb-oomd.service.d/fb_cgroups_slice_override.conf
# This file is maintained by Chef. Do not edit, all changes will be
# overwritten. See fb_cgroups/README.md

[Service]
MemoryLow=64M
OOMScoreAdjust=-1000
MemoryMin=64M
Slice=hostcritical.slice
```

They are applied by Chef and are active on an aliased service but we need to have a parity for them in MetalOS as well.

Reviewed By: chengxiong-ruan

Differential Revision: D59024999

fbshipit-source-id: 22986443fc0be86793b3ac5f242c63386481b3f2
  • Loading branch information
Serge Dubrouski authored and facebook-github-bot committed Jun 26, 2024
1 parent 485f17c commit 4ca0347
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/oomd/cfgen/src/cfgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,16 @@ fn get_host_type(node: &Node) -> HostType {

fn main() -> anyhow::Result<()> {
let mut b = libcfgen::Builder::new();
b = b.dynamic_json("oomd2.json", oomd_json);
b = b.dynamic_json(
if libcfgen::context()?
.is_some_and(|c| c.consumer() == libcfgen::ConfigConsumer::METALOS_WDS)
{
"etc/oomd2.json"
} else {
"oomd2.json"
},
oomd_json,
);
b = b.dropin(|node| Ok(oomd_dropin(node)));
b.run()
}
Expand Down

0 comments on commit 4ca0347

Please sign in to comment.