mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-15 13:58:55 +00:00
runtime-rs: Add Spec annotation to help pass image information
We need get the relevent image ref from OCI runtime Spec, especially the annotation of it. Fixes #10690 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use agent::{Agent, Storage};
|
use agent::{Agent, Storage};
|
||||||
@@ -100,10 +101,11 @@ impl ResourceManager {
|
|||||||
root: &oci::Root,
|
root: &oci::Root,
|
||||||
bundle_path: &str,
|
bundle_path: &str,
|
||||||
rootfs_mounts: &[Mount],
|
rootfs_mounts: &[Mount],
|
||||||
|
annotations: &HashMap<String, String>,
|
||||||
) -> Result<Arc<dyn Rootfs>> {
|
) -> Result<Arc<dyn Rootfs>> {
|
||||||
let inner = self.inner.read().await;
|
let inner = self.inner.read().await;
|
||||||
inner
|
inner
|
||||||
.handler_rootfs(cid, root, bundle_path, rootfs_mounts)
|
.handler_rootfs(cid, root, bundle_path, rootfs_mounts, annotations)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
use std::{sync::Arc, thread};
|
use std::{collections::HashMap, sync::Arc, thread};
|
||||||
|
|
||||||
use agent::{types::Device, Agent, OnlineCPUMemRequest, Storage};
|
use agent::{types::Device, Agent, OnlineCPUMemRequest, Storage};
|
||||||
use anyhow::{anyhow, Context, Ok, Result};
|
use anyhow::{anyhow, Context, Ok, Result};
|
||||||
@@ -320,6 +320,7 @@ impl ResourceManagerInner {
|
|||||||
root: &oci::Root,
|
root: &oci::Root,
|
||||||
bundle_path: &str,
|
bundle_path: &str,
|
||||||
rootfs_mounts: &[Mount],
|
rootfs_mounts: &[Mount],
|
||||||
|
annotations: &HashMap<String, String>,
|
||||||
) -> Result<Arc<dyn Rootfs>> {
|
) -> Result<Arc<dyn Rootfs>> {
|
||||||
self.rootfs_resource
|
self.rootfs_resource
|
||||||
.handler_rootfs(
|
.handler_rootfs(
|
||||||
@@ -331,6 +332,7 @@ impl ResourceManagerInner {
|
|||||||
root,
|
root,
|
||||||
bundle_path,
|
bundle_path,
|
||||||
rootfs_mounts,
|
rootfs_mounts,
|
||||||
|
annotations,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ mod block_rootfs;
|
|||||||
pub mod virtual_volume;
|
pub mod virtual_volume;
|
||||||
use hypervisor::{device::device_manager::DeviceManager, Hypervisor};
|
use hypervisor::{device::device_manager::DeviceManager, Hypervisor};
|
||||||
|
|
||||||
use std::{sync::Arc, vec::Vec};
|
use std::{collections::HashMap, sync::Arc, vec::Vec};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use self::{block_rootfs::is_block_rootfs, nydus_rootfs::NYDUS_ROOTFS_TYPE};
|
use self::{block_rootfs::is_block_rootfs, nydus_rootfs::NYDUS_ROOTFS_TYPE};
|
||||||
@@ -67,6 +67,7 @@ impl RootFsResource {
|
|||||||
root: &oci::Root,
|
root: &oci::Root,
|
||||||
bundle_path: &str,
|
bundle_path: &str,
|
||||||
rootfs_mounts: &[Mount],
|
rootfs_mounts: &[Mount],
|
||||||
|
_annotations: &HashMap<String, String>,
|
||||||
) -> Result<Arc<dyn Rootfs>> {
|
) -> Result<Arc<dyn Rootfs>> {
|
||||||
match rootfs_mounts {
|
match rootfs_mounts {
|
||||||
// if rootfs_mounts is empty
|
// if rootfs_mounts is empty
|
||||||
|
@@ -110,6 +110,8 @@ impl Container {
|
|||||||
// is 'true'.
|
// is 'true'.
|
||||||
None => true,
|
None => true,
|
||||||
};
|
};
|
||||||
|
let annotations = spec.annotations().clone().unwrap_or_default();
|
||||||
|
|
||||||
amend_spec(
|
amend_spec(
|
||||||
&mut spec,
|
&mut spec,
|
||||||
toml_config.runtime.disable_guest_seccomp,
|
toml_config.runtime.disable_guest_seccomp,
|
||||||
@@ -131,6 +133,7 @@ impl Container {
|
|||||||
root,
|
root,
|
||||||
&config.bundle,
|
&config.bundle,
|
||||||
&config.rootfs_mounts,
|
&config.rootfs_mounts,
|
||||||
|
&annotations,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.context("handler rootfs")?;
|
.context("handler rootfs")?;
|
||||||
|
Reference in New Issue
Block a user