Skip to content

Commit

Permalink
Merge pull request kata-containers#6007 from jongwu/single_container
Browse files Browse the repository at this point in the history
runtime-rs: add Single Container support
  • Loading branch information
liubin authored Jan 11, 2023
2 parents 07e77f5 + 464d4c9 commit 0ec4aa1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libs/kata-sys-util/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn get_container_type(spec: &oci::Spec) -> Result<ContainerType, Error> {
pub fn get_shim_id_info() -> Result<ShimIdInfo, Error> {
let spec = load_oci_spec()?;
match get_container_type(&spec)? {
ContainerType::PodSandbox => Ok(ShimIdInfo::Sandbox),
ContainerType::PodSandbox | ContainerType::SingleContainer => Ok(ShimIdInfo::Sandbox),
ContainerType::PodContainer => {
for k in CRI_SANDBOX_ID_KEY_LIST {
if let Some(sandbox_id) = spec.annotations.get(*k) {
Expand Down
5 changes: 5 additions & 0 deletions src/libs/kata-types/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub(crate) const SANDBOX: &str = "sandbox";
// docker: a sandbox sandbox container
pub(crate) const PODSANDBOX: &str = "podsandbox";

pub(crate) const SINGLE_CONTAINER: &str = "single_container";

const STATE_READY: &str = "ready";
const STATE_RUNNING: &str = "running";
const STATE_STOPPED: &str = "stopped";
Expand All @@ -45,6 +47,8 @@ pub enum ContainerType {
PodContainer,
/// A pod sandbox.
PodSandbox,
/// A single container.
SingleContainer,
}

impl ContainerType {
Expand All @@ -64,6 +68,7 @@ impl Display for ContainerType {
match self {
ContainerType::PodContainer => write!(f, "{}", POD_CONTAINER),
ContainerType::PodSandbox => write!(f, "{}", POD_SANDBOX),
ContainerType::SingleContainer => write!(f, "{}", SINGLE_CONTAINER),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/kata-types/src/k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn container_type(spec: &oci::Spec) -> ContainerType {
}
}

ContainerType::PodSandbox
ContainerType::SingleContainer
}

/// Determine the k8s sandbox ID from OCI annotations.
Expand Down Expand Up @@ -269,7 +269,7 @@ mod tests {
// default
assert_eq!(
container_type_with_id(&spec),
(ContainerType::PodSandbox, None)
(ContainerType::SingleContainer, None)
);

// crio sandbox
Expand Down
2 changes: 1 addition & 1 deletion src/runtime-rs/crates/shim/src/shim_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl ShimExecutor {
let (container_type, id) = k8s::container_type_with_id(&spec);

match container_type {
ContainerType::PodSandbox => {
ContainerType::PodSandbox | ContainerType::SingleContainer => {
let address = self.socket_address(&self.args.id)?;
let socket = new_listener(&address)?;
let child_pid = self.create_shim_process(socket)?;
Expand Down

0 comments on commit 0ec4aa1

Please sign in to comment.