mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-15 06:34:03 +00:00
runk: Use the original Kill command instead of the customed it.
We can remove the custom kill command. Fixes: #6083 Signed-off-by: utam0k <k0ma@utam0k.jp>
This commit is contained in:
parent
0f9e23a3d9
commit
095e8fdef4
@ -3,9 +3,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use crate::Kill;
|
||||
use anyhow::Result;
|
||||
use libcontainer::container::Container;
|
||||
use liboci_cli::Kill;
|
||||
use nix::sys::signal::Signal;
|
||||
use slog::{info, Logger};
|
||||
use std::{convert::TryFrom, path::Path, str::FromStr};
|
||||
@ -15,9 +15,6 @@ pub fn run(opts: Kill, state_root: &Path, logger: &Logger) -> Result<()> {
|
||||
let container = Container::load(state_root, container_id)?;
|
||||
let sig = parse_signal(&opts.signal)?;
|
||||
|
||||
// TODO: liboci-cli does not support --all option for kill command.
|
||||
// After liboci-cli supports the option, we will change the following code.
|
||||
// as a workaround we use a custom Kill command.
|
||||
let all = opts.all;
|
||||
container.kill(sig, all)?;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use clap::{crate_description, crate_name, Parser};
|
||||
use liboci_cli::{CommonCmd, GlobalOpts};
|
||||
use liboci_cli::{Create, Delete, Start, State};
|
||||
use liboci_cli::{Create, Delete, Kill, Start, State};
|
||||
use slog::{o, Logger};
|
||||
use slog_async::AsyncGuard;
|
||||
use std::{
|
||||
@ -26,39 +26,20 @@ enum SubCommand {
|
||||
Standard(StandardCmd),
|
||||
#[clap(flatten)]
|
||||
Common(CommonCmd),
|
||||
#[clap(flatten)]
|
||||
Custom(CustomCmd),
|
||||
/// Launch an init process (do not call it outside of runk)
|
||||
Init {},
|
||||
}
|
||||
|
||||
// Copy from https://github.com/containers/youki/blob/v0.0.3/crates/liboci-cli/src/lib.rs#L38-L44
|
||||
// but without Kill command.
|
||||
#[derive(Parser, Debug)]
|
||||
pub enum StandardCmd {
|
||||
Create(Create),
|
||||
Start(Start),
|
||||
State(State),
|
||||
Delete(Delete),
|
||||
}
|
||||
|
||||
// as a workaround to support --all option for kill command,
|
||||
// we use a custom implementation of Kill.
|
||||
#[derive(Parser, Debug)]
|
||||
pub enum CustomCmd {
|
||||
Kill(Kill),
|
||||
}
|
||||
|
||||
/// Send the specified signal to the container
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct Kill {
|
||||
#[clap(forbid_empty_values = true, required = true)]
|
||||
pub container_id: String,
|
||||
pub signal: String,
|
||||
#[clap(short, long)]
|
||||
pub all: bool,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(version, author, about = crate_description!())]
|
||||
struct Cli {
|
||||
@ -75,6 +56,7 @@ async fn cmd_run(subcmd: SubCommand, root_path: &Path, logger: &Logger) -> Resul
|
||||
StandardCmd::Start(start) => commands::start::run(start, root_path, logger).await,
|
||||
StandardCmd::Delete(delete) => commands::delete::run(delete, root_path, logger).await,
|
||||
StandardCmd::State(state) => commands::state::run(state, root_path, logger),
|
||||
StandardCmd::Kill(kill) => commands::kill::run(kill, root_path, logger),
|
||||
},
|
||||
SubCommand::Common(cmd) => match cmd {
|
||||
CommonCmd::Run(run) => commands::run::run(run, root_path, logger).await,
|
||||
@ -88,9 +70,6 @@ async fn cmd_run(subcmd: SubCommand, root_path: &Path, logger: &Logger) -> Resul
|
||||
return Err(anyhow!("command is not implemented yet"));
|
||||
}
|
||||
},
|
||||
SubCommand::Custom(cmd) => match cmd {
|
||||
CustomCmd::Kill(kill) => commands::kill::run(kill, root_path, logger),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user