Skip to content

Commit 8770b4b

Browse files
committed
fix: add cpu constraints to oci config
1 parent f4ea5e9 commit 8770b4b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/edge/infra/client/manager/src/runner/oci_config.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ use std::path::Path;
44

55
use super::{partial_oci_config::PartialOciConfigUser, seccomp};
66

7+
// CPU period in microseconds.
8+
//
9+
// https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt
10+
const CPU_PERIOD: u64 = 100000;
11+
712
pub struct ConfigOpts<'a> {
813
pub runner_path: &'a Path,
914
pub netns_path: &'a Path,
@@ -89,14 +94,8 @@ pub fn config(opts: ConfigOpts) -> Result<serde_json::Value> {
8994
// If `quota` is greater than `period`, it is allowed to use multiple cores.
9095
//
9196
// Read more: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/sec-cpu
92-
// "quota": CPU_PERIOD * cpu / 1_000,
93-
// "period": CPU_PERIOD,
94-
// Use the env var for the CPU since Nomad handles assigning CPUs to each task
95-
// "cpus": if cpu >= 1_000 {
96-
// Some(template_env_var("NOMAD_CPU_CORES"))
97-
// } else {
98-
// None
99-
// }
97+
"quota": CPU_PERIOD * opts.cpu / 1_000,
98+
"period": CPU_PERIOD,
10099
}))
101100
} else {
102101
None

0 commit comments

Comments
 (0)