-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from Furisto/cg-add
Seperate adding tasks to cgroups and applying resource restrictions
- Loading branch information
Showing
18 changed files
with
217 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
use std::path::Path; | ||
use std::{fs, path::Path}; | ||
|
||
use anyhow::Result; | ||
use nix::unistd::Pid; | ||
|
||
use oci_spec::LinuxResources; | ||
|
||
use crate::cgroups::common::{self, CGROUP_PROCS}; | ||
|
||
pub trait Controller { | ||
fn apply(linux_resources: &LinuxResources, cgroup_root: &Path, pid: Pid) -> Result<()>; | ||
fn add_task(pid: Pid, cgroup_path: &Path) -> Result<()> { | ||
fs::create_dir_all(cgroup_path)?; | ||
common::write_cgroup_file(cgroup_path.join(CGROUP_PROCS), pid)?; | ||
Ok(()) | ||
} | ||
|
||
fn apply(linux_resources: &LinuxResources, cgroup_root: &Path) -> Result<()>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
use std::fmt::Display; | ||
|
||
#[derive(Hash, PartialEq, Eq, Debug, Clone)] | ||
pub enum ControllerType { | ||
Cpu, | ||
CpuAcct, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.