-
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 #536 from knight42/feat/add-update-cmd
implement the update subcommand(partially)
- Loading branch information
Showing
10 changed files
with
105 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use clap::Parser; | ||
|
||
/// Update running container resource constraints | ||
#[derive(Parser, Debug)] | ||
pub struct Update { | ||
#[clap(forbid_empty_values = true, required = true)] | ||
pub container_id: String, | ||
|
||
/// Set the maximum number of processes allowed in the container | ||
#[clap(long)] | ||
pub pids_limit: Option<i64>, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::path::PathBuf; | ||
|
||
use crate::commands::create_cgroup_manager; | ||
use anyhow::Result; | ||
use libcgroups::{self, common::ControllerOpt}; | ||
use liboci_cli::Update; | ||
use oci_spec::runtime::{LinuxPids, LinuxResources}; | ||
|
||
pub fn update(args: Update, root_path: PathBuf) -> Result<()> { | ||
let cmanager = create_cgroup_manager(root_path, &args.container_id)?; | ||
|
||
let mut linux_res = LinuxResources::default(); | ||
if let Some(new_pids_limit) = args.pids_limit { | ||
let mut pids = LinuxPids::default(); | ||
pids.set_limit(new_pids_limit); | ||
linux_res.set_pids(Some(pids)); | ||
} | ||
|
||
cmanager.apply(&ControllerOpt { | ||
resources: &linux_res, | ||
disable_oom_killer: false, | ||
oom_score_adj: None, | ||
freezer_state: None, | ||
})?; | ||
Ok(()) | ||
} |
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