-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Liboci additional flags and subcommands, as required by ociplex #2149
Conversation
Add the missing command-line options as documented for runc, and also reorder the options to match the documentation: https://github.com/opencontainers/runc/blob/main/man/runc-checkpoint.8.md (This does not mean that they are necessarily implemented) Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
The --no-pivot option is documented in https://github.com/opencontainers/runc/blob/main/man/runc-create.8.md Also change the options order in order to match the doc, this makes the code a bit easier to maintain. Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2149 +/- ##
==========================================
- Coverage 64.82% 64.64% -0.18%
==========================================
Files 129 131 +2
Lines 14769 14809 +40
==========================================
Hits 9574 9574
- Misses 5195 5235 +40 |
Also, you can run |
Add the missing command-line options for the exec subcommand. Reference: https://github.com/opencontainers/runc/blob/main/man/runc-exec.8.md Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Also change the order to match the documentation in https://github.com/opencontainers/runc/blob/main/man/runc-run.8.md Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Add command-line options as documented in https://github.com/opencontainers/runc/blob/main/man/runc-update.8.md Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Add the missing bundle option, as documented in https://github.com/opencontainers/runc/blob/main/man/runc-spec.8.md Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
The 'features' subcommand is not publicly documented yet, but it was introduced in `runc` in opencontainers/runc#3296. Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
The `features` subcommand is implemented in `runc`, but not documented. See opencontainers/runc#3296 Signed-off-by: Christophe de Dinechin <dinechin@redhat.com> Suggested-by: Toru Komatsu <k0ma@utam0k.jp>
Add the command-line options documented in https://github.com/opencontainers/runc/blob/main/man/runc-list.8.md Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
We have to pick an order for the command-line options. Let's just use the same order as in the runc documentation (since this will also be the order shown by the command-line help) Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
The `features` subcommand is now officially documented. Update the links to the documentation. Signed-off-by: Christophe de Dinechin <dinechin@redhat.com> Suggested-by: Toru Komatsu <k0ma@utam0k.jp>
It is better to describe the intent of the parsing than how it is done. Signed-off-by: Christophe de Dinechin <dinechin@redhat.com> Suggested-by: Eric Fang <yihuaf@unkies.org>
@c3d May I ask you to fix the error from clippy? If you need, please ignore it |
I saw an error about variants size pertaining to the subcommands.
There is indeed a lot of variations between the subcommands, since this branch adds a lot of command-specific options. I think that this is expected. Adding boxing is probably of little value for command-line arguments (they won't use that much memory to start with). Is there a way to tell the rust linter to ignore this specific case? |
Try:
The main issue is that this gets triggered in Alternatively, you can box up a few of the large structure such as |
Well, I'm co-developing the "other" user at the moment (a project called
I'll give this approach a try. My initial thinking is that this was more overhead than the difference in size, knowing that we don't have that many command structures to start with in a normal application, so the extra cost of heap management might not be worth it. |
The `Exec` structure is large compared to the others. This causes `just lint` to complain: ``` error: large size difference between variants --> crates/youki/src/main.rs:48:1 | 48 | / enum SubCommand { 49 | | // Standard and common commands handled by the liboci_cli crate 50 | | #[clap(flatten)] 51 | | Standard(liboci_cli::StandardCmd), | | --------------------------------- the second-largest variant contains at least 104 bytes 52 | | #[clap(flatten)] 53 | | Common(liboci_cli::CommonCmd), | | ----------------------------- the largest variant contains at least 320 bytes ... | 57 | | Completion(commands::completion::Completion), 58 | | } | |_^ the entire enum is at least 320 bytes | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant = note: `-D clippy::large-enum-variant` implied by `-D warnings` help: consider boxing the large fields to reduce the total size of the enum | 53 | Common(Box<liboci_cli::CommonCmd>), | ~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Boxing the `Exec` variant prevents this problem from happening. Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
@yihuaf I added a separate commit. Do you see this as an improvement? I can't say I like it much, but it does eliminate the |
Yea I don't like this as well, especially since this breaks up the liboci-cli apis to make each sub command argument inconsistent. The user now have to pay attention on which is box and which is not. How about we box the SubCommand in the application? In this way, each users of the liboci-cli can decide how to proceed or if to enforce the lint rule at all. I find this to be a better alternative. In the following diff, I boxed up the [eng@stardust youki]$ git diff
diff --git a/crates/liboci-cli/src/lib.rs b/crates/liboci-cli/src/lib.rs
index 6dafaf44..89c48a6d 100644
--- a/crates/liboci-cli/src/lib.rs
+++ b/crates/liboci-cli/src/lib.rs
@@ -52,7 +52,7 @@ pub enum StandardCmd {
pub enum CommonCmd {
Checkpointt(Checkpoint),
Events(Events),
- Exec(Box<Exec>),
+ Exec(Exec),
Features(Features),
List(List),
Pause(Pause),
diff --git a/crates/youki/src/main.rs b/crates/youki/src/main.rs
index 09374a41..6a92be8d 100644
--- a/crates/youki/src/main.rs
+++ b/crates/youki/src/main.rs
@@ -48,9 +48,9 @@ struct Opts {
enum SubCommand {
// Standard and common commands handled by the liboci_cli crate
#[clap(flatten)]
- Standard(liboci_cli::StandardCmd),
+ Standard(Box<liboci_cli::StandardCmd>),
#[clap(flatten)]
- Common(liboci_cli::CommonCmd),
+ Common(Box<liboci_cli::CommonCmd>),
// Youki specific extensions
Info(info::Info),
@@ -106,7 +106,7 @@ fn main() -> Result<()> {
let systemd_cgroup = opts.global.systemd_cgroup;
let cmd_result = match opts.subcmd {
- SubCommand::Standard(cmd) => match cmd {
+ SubCommand::Standard(cmd) => match *cmd {
StandardCmd::Create(create) => {
commands::create::create(create, root_path, systemd_cgroup)
}
@@ -115,12 +115,12 @@ fn main() -> Result<()> {
StandardCmd::Delete(delete) => commands::delete::delete(delete, root_path),
StandardCmd::State(state) => commands::state::state(state, root_path),
},
- SubCommand::Common(cmd) => match cmd {
+ SubCommand::Common(cmd) => match *cmd {
CommonCmd::Checkpointt(checkpoint) => {
commands::checkpoint::checkpoint(checkpoint, root_path)
}
CommonCmd::Events(events) => commands::events::events(events, root_path),
- CommonCmd::Exec(exec) => match commands::exec::exec(*exec, root_path) {
+ CommonCmd::Exec(exec) => match commands::exec::exec(exec, root_path) {
Ok(exit_code) => std::process::exit(exit_code),
Err(e) => {
eprintln!("exec failed : {e}");
[eng@stardust youki]$ If you are OK with this approach, I can push the commit to this PR and merge. |
Signed-off-by: yihuaf <yihuaf@unkies.org>
I will help you to get this merged since this is the last outstanding items. |
These are a few changes in the
liboci-cli
crate that are necessary for some additional commands that I am implementing inociplex
.