mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-16 04:44:21 +01:00
agent/image: export the image service singleton instance
Export the image service singleton instance. Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
This commit is contained in:
@@ -36,14 +36,20 @@ const KATA_CC_IMAGE_WORK_DIR: &str = "/run/image/";
|
||||
const KATA_CC_PAUSE_BUNDLE: &str = "/pause_bundle";
|
||||
const CONFIG_JSON: &str = "config.json";
|
||||
|
||||
#[rustfmt::skip]
|
||||
lazy_static! {
|
||||
pub static ref IMAGE_SERVICE: Mutex<Option<ImageService>> = Mutex::new(None);
|
||||
}
|
||||
|
||||
// Convenience function to obtain the scope logger.
|
||||
fn sl() -> slog::Logger {
|
||||
slog_scope::logger().new(o!("subsystem" => "cgroups"))
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ImageService {
|
||||
sandbox: Arc<Mutex<Sandbox>>,
|
||||
attestation_agent_started: AtomicBool,
|
||||
attestation_agent_started: Arc<AtomicBool>,
|
||||
image_client: Arc<Mutex<ImageClient>>,
|
||||
container_count: Arc<AtomicU16>,
|
||||
}
|
||||
@@ -67,7 +73,7 @@ impl ImageService {
|
||||
|
||||
Self {
|
||||
sandbox,
|
||||
attestation_agent_started: AtomicBool::new(false),
|
||||
attestation_agent_started: Arc::new(AtomicBool::new(false)),
|
||||
image_client: Arc::new(Mutex::new(image_client)),
|
||||
container_count: Arc::new(AtomicU16::new(0)),
|
||||
}
|
||||
|
||||
@@ -207,7 +207,8 @@ impl AgentService {
|
||||
"receive createcontainer, storages: {:?}", &req.storages
|
||||
);
|
||||
|
||||
// Merge the image bundle OCI spec into the container creation request OCI spec.
|
||||
// In case of pulling image inside guest, we need to merge the image bundle OCI spec
|
||||
// into the container creation request OCI spec.
|
||||
self.merge_bundle_oci(&mut oci).await?;
|
||||
|
||||
// Some devices need some extra processing (the ones invoked with
|
||||
@@ -1773,9 +1774,11 @@ pub async fn start(
|
||||
let health_service = Box::new(HealthService {}) as Box<dyn health_ttrpc::Health + Send + Sync>;
|
||||
let hservice = health_ttrpc::create_health(Arc::new(health_service));
|
||||
|
||||
let image_service = image_rpc::ImageService::new(s);
|
||||
*image_rpc::IMAGE_SERVICE.lock().await = Some(image_service.clone());
|
||||
let image_service =
|
||||
Box::new(image_rpc::ImageService::new(s)) as Box<dyn image_ttrpc::Image + Send + Sync>;
|
||||
let iservice = image_ttrpc::create_image(Arc::new(image_service));
|
||||
Arc::new(Box::new(image_service) as Box<dyn image_ttrpc::Image + Send + Sync>);
|
||||
let iservice = image_ttrpc::create_image(image_service);
|
||||
|
||||
let server = TtrpcServer::new()
|
||||
.bind(server_address)?
|
||||
|
||||
Reference in New Issue
Block a user