mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-18 01:13:56 +00:00
Merge pull request #6007 from jongwu/single_container
runtime-rs: add Single Container support
This commit is contained in:
commit
0ec4aa1a86
@ -68,7 +68,7 @@ pub fn get_container_type(spec: &oci::Spec) -> Result<ContainerType, Error> {
|
|||||||
pub fn get_shim_id_info() -> Result<ShimIdInfo, Error> {
|
pub fn get_shim_id_info() -> Result<ShimIdInfo, Error> {
|
||||||
let spec = load_oci_spec()?;
|
let spec = load_oci_spec()?;
|
||||||
match get_container_type(&spec)? {
|
match get_container_type(&spec)? {
|
||||||
ContainerType::PodSandbox => Ok(ShimIdInfo::Sandbox),
|
ContainerType::PodSandbox | ContainerType::SingleContainer => Ok(ShimIdInfo::Sandbox),
|
||||||
ContainerType::PodContainer => {
|
ContainerType::PodContainer => {
|
||||||
for k in CRI_SANDBOX_ID_KEY_LIST {
|
for k in CRI_SANDBOX_ID_KEY_LIST {
|
||||||
if let Some(sandbox_id) = spec.annotations.get(*k) {
|
if let Some(sandbox_id) = spec.annotations.get(*k) {
|
||||||
|
@ -19,6 +19,8 @@ pub(crate) const SANDBOX: &str = "sandbox";
|
|||||||
// docker: a sandbox sandbox container
|
// docker: a sandbox sandbox container
|
||||||
pub(crate) const PODSANDBOX: &str = "podsandbox";
|
pub(crate) const PODSANDBOX: &str = "podsandbox";
|
||||||
|
|
||||||
|
pub(crate) const SINGLE_CONTAINER: &str = "single_container";
|
||||||
|
|
||||||
const STATE_READY: &str = "ready";
|
const STATE_READY: &str = "ready";
|
||||||
const STATE_RUNNING: &str = "running";
|
const STATE_RUNNING: &str = "running";
|
||||||
const STATE_STOPPED: &str = "stopped";
|
const STATE_STOPPED: &str = "stopped";
|
||||||
@ -45,6 +47,8 @@ pub enum ContainerType {
|
|||||||
PodContainer,
|
PodContainer,
|
||||||
/// A pod sandbox.
|
/// A pod sandbox.
|
||||||
PodSandbox,
|
PodSandbox,
|
||||||
|
/// A single container.
|
||||||
|
SingleContainer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContainerType {
|
impl ContainerType {
|
||||||
@ -64,6 +68,7 @@ impl Display for ContainerType {
|
|||||||
match self {
|
match self {
|
||||||
ContainerType::PodContainer => write!(f, "{}", POD_CONTAINER),
|
ContainerType::PodContainer => write!(f, "{}", POD_CONTAINER),
|
||||||
ContainerType::PodSandbox => write!(f, "{}", POD_SANDBOX),
|
ContainerType::PodSandbox => write!(f, "{}", POD_SANDBOX),
|
||||||
|
ContainerType::SingleContainer => write!(f, "{}", SINGLE_CONTAINER),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ pub fn container_type(spec: &oci::Spec) -> ContainerType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerType::PodSandbox
|
ContainerType::SingleContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine the k8s sandbox ID from OCI annotations.
|
/// Determine the k8s sandbox ID from OCI annotations.
|
||||||
@ -269,7 +269,7 @@ mod tests {
|
|||||||
// default
|
// default
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
container_type_with_id(&spec),
|
container_type_with_id(&spec),
|
||||||
(ContainerType::PodSandbox, None)
|
(ContainerType::SingleContainer, None)
|
||||||
);
|
);
|
||||||
|
|
||||||
// crio sandbox
|
// crio sandbox
|
||||||
|
@ -38,7 +38,7 @@ impl ShimExecutor {
|
|||||||
let (container_type, id) = k8s::container_type_with_id(&spec);
|
let (container_type, id) = k8s::container_type_with_id(&spec);
|
||||||
|
|
||||||
match container_type {
|
match container_type {
|
||||||
ContainerType::PodSandbox => {
|
ContainerType::PodSandbox | ContainerType::SingleContainer => {
|
||||||
let address = self.socket_address(&self.args.id)?;
|
let address = self.socket_address(&self.args.id)?;
|
||||||
let socket = new_listener(&address)?;
|
let socket = new_listener(&address)?;
|
||||||
let child_pid = self.create_shim_process(socket)?;
|
let child_pid = self.create_shim_process(socket)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user