From 4ca0347cb1d58b0f7a8bc9a79541e9ef21614d56 Mon Sep 17 00:00:00 2001 From: Serge Dubrouski Date: Wed, 26 Jun 2024 08:17:54 -0700 Subject: [PATCH] MetalOS compatibility 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 --- src/oomd/cfgen/src/cfgen.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/oomd/cfgen/src/cfgen.rs b/src/oomd/cfgen/src/cfgen.rs index ce4e65da..333f69db 100644 --- a/src/oomd/cfgen/src/cfgen.rs +++ b/src/oomd/cfgen/src/cfgen.rs @@ -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() }