From 9c1ac3d457f09d3f22c046d71afe1f1d17b4a5b3 Mon Sep 17 00:00:00 2001 From: Ji-Xinyou Date: Wed, 21 Sep 2022 17:36:56 +0800 Subject: [PATCH] runtime-rs: return port on agent-url req Add the server vport (1024) when requesting agent-url Fixes: #5213 Signed-off-by: Ji-Xinyou --- src/runtime-rs/crates/agent/src/kata/mod.rs | 6 +++++- .../crates/runtimes/virt_container/src/sandbox.rs | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/runtime-rs/crates/agent/src/kata/mod.rs b/src/runtime-rs/crates/agent/src/kata/mod.rs index 920b55340c..d87965f612 100644 --- a/src/runtime-rs/crates/agent/src/kata/mod.rs +++ b/src/runtime-rs/crates/agent/src/kata/mod.rs @@ -130,7 +130,11 @@ impl KataAgent { pub(crate) async fn agent_sock(&self) -> Result { let inner = self.inner.read().await; - Ok(inner.socket_address.clone()) + Ok(format!( + "{}:{}", + inner.socket_address.clone(), + inner.config.server_port + )) } pub(crate) async fn agent_config(&self) -> AgentConfig { diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs index ebe0a4e204..968c164418 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs @@ -15,7 +15,10 @@ use common::{ }; use containerd_shim_protos::events::task::TaskOOM; use hypervisor::{dragonball::Dragonball, Hypervisor, HYPERVISOR_DRAGONBALL}; -use kata_types::config::TomlConfig; +use kata_types::config::{ + default::{DEFAULT_AGENT_LOG_PORT, DEFAULT_AGENT_VSOCK_PORT}, + TomlConfig, +}; use resource::{ manager::ManagerArgs, network::{NetworkConfig, NetworkWithNetNsConfig}, @@ -299,8 +302,8 @@ impl Persist for VirtSandbox { let agent = Arc::new(KataAgent::new(kata_types::config::Agent { debug: true, enable_tracing: false, - server_port: 1024, - log_port: 1025, + server_port: DEFAULT_AGENT_VSOCK_PORT, + log_port: DEFAULT_AGENT_LOG_PORT, dial_timeout_ms: 10, reconnect_timeout_ms: 3_000, request_timeout_ms: 30_000,