mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-24 10:17:21 +00:00
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 <alex.lyn@antgroup.com>
This commit is contained in:
committed by
Fabiano Fidêncio
parent
a47c0cdf66
commit
71ddbac56d
@@ -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,
|
||||
|
Reference in New Issue
Block a user