mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
kata-types: add single_container support
For now, only pod_sandbox and pod_container are supported. It doesn't cover the case that container started by ctr which is a single_container defined in kata 2.0. port the single_container kata type from kata 2.0 to kata 3.0. Fixes: #6006 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
parent
2c10b37172
commit
5f9c892e48
@ -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) {
|
||||
|
@ -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";
|
||||
@ -45,6 +47,8 @@ pub enum ContainerType {
|
||||
PodContainer,
|
||||
/// A pod sandbox.
|
||||
PodSandbox,
|
||||
/// A single container.
|
||||
SingleContainer,
|
||||
}
|
||||
|
||||
impl ContainerType {
|
||||
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ pub fn container_type(spec: &oci::Spec) -> ContainerType {
|
||||
}
|
||||
}
|
||||
|
||||
ContainerType::PodSandbox
|
||||
ContainerType::SingleContainer
|
||||
}
|
||||
|
||||
/// Determine the k8s sandbox ID from OCI annotations.
|
||||
@ -269,7 +269,7 @@ mod tests {
|
||||
// default
|
||||
assert_eq!(
|
||||
container_type_with_id(&spec),
|
||||
(ContainerType::PodSandbox, None)
|
||||
(ContainerType::SingleContainer, None)
|
||||
);
|
||||
|
||||
// crio sandbox
|
||||
|
Loading…
Reference in New Issue
Block a user