From 71ddbac56da58b65c3b615b2b678bfd59076b62b Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Sun, 7 Sep 2025 20:22:19 +0800 Subject: [PATCH] runtime-rs: Correctly set CONTAINER_TYPE_KEY within OCI Spec annotation With the help of `update_ocispec_annotations`, we'll add the contaienr type key with "io.katacontainers.pkg.oci.container_type" and its corresponding type "pod_sandbox" when it's pause container and "pod_container" when it's an other containers. Signed-off-by: Alex Lyn --- .../src/container_manager/container.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs index dadc0e978a..379ec35baa 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs @@ -17,7 +17,11 @@ use common::{ }, }; use kata_sys_util::k8s::update_ephemeral_storage_type; -use kata_types::k8s; +use kata_types::{ + annotations::CONTAINER_TYPE_KEY, + container::{update_ocispec_annotations, POD_CONTAINER, POD_SANDBOX}, + k8s::{self, container_type}, +}; use oci_spec::runtime::{self as oci, LinuxDeviceCgroup}; use oci::{LinuxResources, Process as OCIProcess}; @@ -111,6 +115,15 @@ impl Container { None => true, }; let annotations = spec.annotations().clone().unwrap_or_default(); + let container_typ = container_type(&spec); + let pod_type_anno = if container_typ.is_pod_container() { + (CONTAINER_TYPE_KEY.to_string(), POD_CONTAINER.to_string()) + } else { + (CONTAINER_TYPE_KEY.to_string(), POD_SANDBOX.to_string()) + }; + let updated_annotations = + update_ocispec_annotations(&annotations, &[], &vec![pod_type_anno]); + spec.set_annotations(Some(updated_annotations.clone())); amend_spec( &mut spec,