Skip to content

Commit

Permalink
Merge branch 'main' into spdx-license
Browse files Browse the repository at this point in the history
  • Loading branch information
dmah42 authored Jun 21, 2024
2 parents eda6d36 + b584bec commit e1b8cc2
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 27 deletions.
1 change: 1 addition & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
As part of the [Nivenly](https://nivenly.org) we have adopted the [Nivenly Covenant](https://nivenly.org/covenant/) as our code of conduct.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Aurae [open-source] project can complement higher order schedulers and control
planes (such as Kubernetes) as Aurae supports the usage of multi-tenant
workloads and enterprise identities all the way down to the socket layer.

[Aurae] is a proud member of the [Nivenly](https://nivenly.org) foundation.

## FOSDEM 2023 Presentation

- Slides: [Link to presentation](https://docs.google.com/presentation/d/1GxKN5tyv4lV2aZdEOUqy3R9tVCat-vrFJyelgFX7b1A/edit#slide=id.g1eef12fba1d_6_53)
Expand Down
9 changes: 9 additions & 0 deletions api/v0/cells/cells.proto
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ message CpuController {
// By default a cgroup has no limit, represented as the literal string "max".
// Not settings this field retains the default of no limit.
optional int64 max = 2;

// The period is used as the scheduling slice. It interacts with
// max (see above) as a given workload will only run for max
// microseconds within period microseconds.
//
// * Minimum: 0
//
// By default a cgroup has period 100000.
optional uint64 period = 3;
}

// Docs: https://docs.kernel.org/admin-guide/cgroup-v2.html#cpuset
Expand Down
5 changes: 3 additions & 2 deletions auraed/src/cells/cell_service/cell_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,13 @@ impl TryFrom<&super::cells::Cell> for CellGraphNode {

impl From<&super::cells::cgroups::CpuController> for CpuController {
fn from(value: &super::cells::cgroups::CpuController) -> Self {
let super::cells::cgroups::CpuController { weight, max } =
let super::cells::cgroups::CpuController { weight, max, period } =
value.clone();

Self {
weight: weight.map(|x| x.into_inner()),
max: max.map(|x| x.into_inner()),
period,
}
}
}
Expand Down Expand Up @@ -660,7 +661,7 @@ mod tests {
// Create a validated cell for the allocate request
let cell = ValidatedCell {
name: CellName::from(cell_name),
cpu: Some(ValidatedCpuController { weight: None, max: None }),
cpu: Some(ValidatedCpuController { weight: None, max: None, period: None }),
cpuset: Some(ValidatedCpusetController { cpus: None, mems: None }),
memory: Some(ValidatedMemoryController {
min: None,
Expand Down
37 changes: 19 additions & 18 deletions auraed/src/cells/cell_service/cells/cgroups/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ use std::str::FromStr;

use super::error::{CgroupsError, Result};

/// This is used as the denominator for the CPU quota/period configuration. This allows users to
/// set the quota as if it was in the unit "µs/s" without worrying about also setting the period.
const MICROSECONDS_PER_SECOND: u64 = 1000000;

#[derive(Debug)]
pub struct Cgroup {
cell_name: CellName,
Expand Down Expand Up @@ -97,23 +93,28 @@ impl Cgroup {
let cpu_builder = LinuxCpuBuilder::default();

// cpu controller
let cpu_builder = if let Some(CpuController { weight, max }) = cpu {
let cpu_builder = if let Some(weight) = weight {
cpu_builder.shares(weight.into_inner())
} else {
cpu_builder
};
let cpu_builder =
if let Some(CpuController { weight, max, period }) = cpu {
let mut cpu_builder = if let Some(weight) = weight {
cpu_builder.shares(weight.into_inner())
} else {
cpu_builder
};

if let Some(max) = max {
cpu_builder
.quota(max.into_inner())
.period(MICROSECONDS_PER_SECOND) // microseconds in a second
cpu_builder = if let Some(max) = max {
cpu_builder.quota(max.into_inner())
} else {
cpu_builder
};

if let Some(period) = period {
cpu_builder.period(period)
} else {
cpu_builder
}
} else {
cpu_builder
}
} else {
cpu_builder
};
};

// cpuset controller
let cpu_builder =
Expand Down
1 change: 1 addition & 0 deletions auraed/src/cells/cell_service/cells/cgroups/cpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ use super::{Limit, Weight};
pub struct CpuController {
pub weight: Option<Weight>,
pub max: Option<Limit>,
pub period: Option<u64>,
}
3 changes: 2 additions & 1 deletion auraed/src/cells/cell_service/cells/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ impl CellSpec {
cgroup_spec: CgroupSpec {
cpu: Some(CpuController {
weight: Some(Weight::new(100)),
max: Some(Limit::new(100000)),
max: None,
period: Some(100000),
}),
cpuset: None,
memory: Some(MemoryController {
Expand Down
3 changes: 3 additions & 0 deletions auraed/src/cells/cell_service/executables/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use tokio::process::{Child, Command};
use tokio::task::JoinHandle;
use tracing::info_span;

// TODO: decide if we're going to use the description or not. Remove if not.
#[allow(dead_code)]

#[derive(Debug)]
pub struct Executable {
pub name: ExecutableName,
Expand Down
24 changes: 18 additions & 6 deletions auraed/src/cells/cell_service/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ pub struct ValidatedCpuController {
#[field_type(Option<i64>)]
#[validate(opt)]
pub max: Option<Limit>,

#[validate(none)]
pub period: Option<u64>,
}

impl CpuControllerTypeValidator for CpuControllerValidator {}

impl From<ValidatedCpuController> for cgroups::cpu::CpuController {
fn from(value: ValidatedCpuController) -> Self {
let ValidatedCpuController { weight, max } = value;
Self { weight, max }
let ValidatedCpuController { weight, max, period } = value;
Self { weight, max, period }
}
}

Expand Down Expand Up @@ -310,7 +313,7 @@ mod tests {
#[test]
fn test_cell_type_cpu_valid() {
let validated = CellValidator::validate_cpu(
Some(CpuController { weight: Some(1000), max: None }),
Some(CpuController { weight: Some(1000), max: None, period: None }),
"field",
Some("parent"),
);
Expand All @@ -320,12 +323,13 @@ mod tests {
let controller = inner.unwrap();
assert_eq!(controller.weight, Some(Weight::new(1000)));
assert_eq!(controller.max, None);
assert_eq!(controller.period, None);
}

#[test]
fn test_cell_type_cpu_weight_too_small() {
let validated = CellValidator::validate_cpu(
Some(CpuController { weight: Some(0), max: None }),
Some(CpuController { weight: Some(0), max: None, period: None }),
"field",
Some("parent"),
);
Expand All @@ -335,7 +339,11 @@ mod tests {
#[test]
fn test_cell_type_cpu_weight_too_large() {
let validated = CellValidator::validate_cpu(
Some(CpuController { weight: Some(10001), max: None }),
Some(CpuController {
weight: Some(10001),
max: None,
period: None,
}),
"field",
Some("parent"),
);
Expand All @@ -345,7 +353,11 @@ mod tests {
#[test]
fn test_cell_type_cpu_max_too_small() {
let validated = CellValidator::validate_cpu(
Some(CpuController { weight: Some(1000), max: Some(-1) }),
Some(CpuController {
weight: Some(1000),
max: Some(-1),
period: None,
}),
"field",
Some("parent"),
);
Expand Down

0 comments on commit e1b8cc2

Please sign in to comment.