{"record":{"id":"6e897010e50a3b35","repo":"risingwavelabs/risingwave","slug":"invalid-format-in-cgroup-cpu-interface-file-path","errorCode":null,"errorMessage":"Invalid format in Cgroup CPU interface file, path: {limit_path}, content: {cpu_limit_string}","messagePattern":"Invalid format in Cgroup CPU interface file, path: (.+?), content: (.+?)","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"warning","filePath":"src/utils/resource_util/src/lib.rs","lineNumber":344,"sourceCode":"    /// Returns the CPU limit when cgroup v2 is utilised.\n    pub fn get_cpu_limit_v2(limit_path: &str, max_value: f32) -> Result<f32, std::io::Error> {\n        let cpu_limit_string = fs_err::read_to_string(limit_path)?;\n\n        let cpu_data: Vec<&str> = cpu_limit_string.split_whitespace().collect();\n        match cpu_data.get(0..2) {\n            Some(cpu_data_values) => {\n                if cpu_data_values[0] == super::DEFAULT_CGROUP_MAX_INDICATOR {\n                    return Ok(max_value);\n                }\n                let cpu_quota = cpu_data_values[0]\n                    .parse::<usize>()\n                    .map_err(|e| parse_error(limit_path, &cpu_limit_string, e))?;\n                let cpu_period = cpu_data_values[1]\n                    .parse::<usize>()\n                    .map_err(|e| parse_error(limit_path, &cpu_limit_string, e))?;\n                Ok((cpu_quota as f32) / (cpu_period as f32))\n            }\n            None => Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidData,\n                format!(\n                    \"Invalid format in Cgroup CPU interface file, path: {limit_path}, content: {cpu_limit_string}\"\n                ),\n            )),\n        }\n    }\n}\n\nmod util {\n    /// Parses the filepath and checks for the existence of `controller_name` in the file.\n    pub fn parse_controller_enable_file_for_cgroup_v2(\n        file_path: &str,\n        controller_name: &str,\n    ) -> bool {\n        match fs_err::read_to_string(file_path) {\n            Ok(controller_string) => {\n                for controller in controller_string.split_whitespace() {","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/utils/resource_util/src/lib.rs#L326-L362","documentation":"For cgroup v2, `get_cpu_limit_v2` expects the `cpu.max` file to contain exactly two whitespace-separated values (`quota period`). If the split yields no such pair, it returns `InvalidData` with this message describing the path and offending content.","triggerScenarios":"Reading a cgroup v2 `cpu.max` file whose content doesn't match `\"<quota> <period>\"` (e.g. empty file, extra fields, or a non-cpu.max file passed as limit_path).","commonSituations":"Minimal/distros container images with odd cgroup layouts; nested cgroups where the resolved path holds unexpected content; runtimes that mount cgroup v1 paths while code probes v2.","solutions":["Inspect the file at the reported path and confirm it contains two integers like `max 100000` or `200000 100000`.","Fix the container's cgroup mount so the v2 unified hierarchy is exposed at the expected path.","Boot the host/container with cgroup v2 unified hierarchy (systemd.unified_cgroup_hierarchy=1) if v2 limits are intended.","Ignore/patch the limit detection to fall back to system CPU when the file format is unexpected."],"exampleFix":"// before\n// cpu.max content: \"\"  -> error\n// after: ensure file exists with valid content\n$ cat /sys/fs/cgroup/cpu.max\nmax 100000","handlingStrategy":"fallback","validationCode":"fn cpu_max_well_formed(path: &str) -> bool {\n    std::fs::read_to_string(path)\n        .map(|c| c.split_whitespace().count() == 2).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match get_cpu_limit_v2(path) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => fallback_to_system_cpu(),\n    other => other?,\n}","preventionTips":["Confirm the host uses cgroup v2 unified hierarchy.","Log file content on failure (the error already embeds it) and alert on layout drift.","Skip container-limit detection when cpu.max is absent or malformed."],"tags":["rust","cgroup-v2","cpu","parse"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}