Skip to content
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

re-export oci-spec in libcontainer #2068

Merged
merged 4 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/libcgroups/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cgroupsv2_devices = ["rbpf", "libbpf-sys", "errno", "libc"]
[dependencies]
nix = "0.26.2"
procfs = "0.15.1"
oci-spec = { version = "^0.6.1", features = ["runtime"] }
oci-spec = { version = "~0.6.1", features = ["runtime"] }
dbus = { version = "0.9.7", optional = true }
fixedbitset = "0.4.2"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -35,7 +35,7 @@ tracing = { version = "0.1.37", features = ["attributes"]}

[dev-dependencies]
anyhow = "1.0"
oci-spec = { version = "^0.6.0", features = ["proptests", "runtime"] }
oci-spec = { version = "~0.6.1", features = ["proptests", "runtime"] }
quickcheck = "1"
mockall = { version = "0.11.4", features = [] }
clap = "4.1.6"
Expand Down
4 changes: 2 additions & 2 deletions crates/libcontainer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fastrand = "^2.0.0"
futures = { version = "0.3", features = ["thread-pool"] }
libc = "0.2.147"
nix = "0.26.2"
oci-spec = { version = "^0.6.1", features = ["runtime"] }
oci-spec = { version = "~0.6.1", features = ["runtime"] }
once_cell = "1.18.0"
procfs = "0.15.1"
prctl = "1.0.0"
Expand All @@ -43,7 +43,7 @@ tracing = { version = "0.1.37", features = ["attributes"]}
safe-path = "0.1.0"

[dev-dependencies]
oci-spec = { version = "^0.6.0", features = ["proptests", "runtime"] }
oci-spec = { version = "~0.6.1", features = ["proptests", "runtime"] }
quickcheck = "1"
serial_test = "2.0.0"
tempfile = "3"
Expand Down
6 changes: 6 additions & 0 deletions crates/libcontainer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ pub mod test_utils;
pub mod tty;
pub mod utils;
pub mod workload;

// Because the `libcontainer` api uses the oci_spec who resides in a different
// crate, we re-export the version of oci_spec this crate uses.
utam0k marked this conversation as resolved.
Show resolved Hide resolved
// Ref: https://github.com/containers/youki/issues/2066
// Ref: https://github.com/rust-lang/api-guidelines/discussions/176
pub use oci_spec;
1 change: 0 additions & 1 deletion crates/youki/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ libcgroups = { version = "0.1.0", path = "../libcgroups", default-features = fal
libcontainer = { version = "0.1.0", path = "../libcontainer", default-features = false }
liboci-cli = { version = "0.1.0", path = "../liboci-cli" }
nix = "0.26.2"
oci-spec = { version = "^0.6.1", features = ["runtime"] }
once_cell = "1.18.0"
pentacle = "1.0.0"
procfs = "0.15.1"
Expand Down
21 changes: 11 additions & 10 deletions crates/youki/src/commands/spec_json.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use anyhow::Result;
use nix;
use oci_spec::runtime::Mount;
use oci_spec::runtime::{
use libcontainer::oci_spec::runtime::Mount;
use libcontainer::oci_spec::runtime::{
LinuxBuilder, LinuxIdMappingBuilder, LinuxNamespace, LinuxNamespaceBuilder, LinuxNamespaceType,
Spec,
};
use nix;
use serde_json::to_writer_pretty;
use std::fs::File;
use std::io::{BufWriter, Write};
Expand All @@ -17,12 +17,13 @@ pub fn get_default() -> Result<Spec> {

pub fn get_rootless() -> Result<Spec> {
// Remove network and user namespace from the default spec
let mut namespaces: Vec<LinuxNamespace> = oci_spec::runtime::get_default_namespaces()
.into_iter()
.filter(|ns| {
ns.typ() != LinuxNamespaceType::Network && ns.typ() != LinuxNamespaceType::User
})
.collect();
let mut namespaces: Vec<LinuxNamespace> =
libcontainer::oci_spec::runtime::get_default_namespaces()
.into_iter()
.filter(|ns| {
ns.typ() != LinuxNamespaceType::Network && ns.typ() != LinuxNamespaceType::User
})
.collect();

// Add user namespace
namespaces.push(
Expand Down Expand Up @@ -50,7 +51,7 @@ pub fn get_rootless() -> Result<Spec> {

// Prepare the mounts

let mut mounts: Vec<Mount> = oci_spec::runtime::get_default_mounts();
let mut mounts: Vec<Mount> = libcontainer::oci_spec::runtime::get_default_mounts();
for mount in &mut mounts {
if mount.destination().eq(Path::new("/sys")) {
mount
Expand Down
2 changes: 1 addition & 1 deletion crates/youki/src/commands/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::commands::create_cgroup_manager;
use anyhow::Result;
use libcgroups::common::CgroupManager;
use libcgroups::{self, common::ControllerOpt};
use libcontainer::oci_spec::runtime::{LinuxPidsBuilder, LinuxResources, LinuxResourcesBuilder};
use liboci_cli::Update;
use oci_spec::runtime::{LinuxPidsBuilder, LinuxResources, LinuxResourcesBuilder};

pub fn update(args: Update, root_path: PathBuf) -> Result<()> {
let cmanager = create_cgroup_manager(root_path, &args.container_id)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/youki/src/workload/wasmedge.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oci_spec::runtime::Spec;
use libcontainer::oci_spec::runtime::Spec;
use wasmedge_sdk::{
config::{CommonConfigOptions, ConfigBuilder, HostRegistrationConfigOptions},
params, VmBuilder,
Expand Down
4 changes: 2 additions & 2 deletions crates/youki/src/workload/wasmer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oci_spec::runtime::Spec;
use libcontainer::oci_spec::runtime::Spec;
use wasmer::{Instance, Module, Store};
use wasmer_wasix::WasiEnv;

Expand Down Expand Up @@ -100,7 +100,7 @@ impl Executor for WasmerExecutor {
mod tests {
use super::*;
use anyhow::{Context, Result};
use oci_spec::runtime::SpecBuilder;
use libcontainer::oci_spec::runtime::SpecBuilder;
use std::collections::HashMap;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/youki/src/workload/wasmtime.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oci_spec::runtime::Spec;
use libcontainer::oci_spec::runtime::Spec;
use wasmtime::*;
use wasmtime_wasi::WasiCtxBuilder;

Expand Down