pub struct KataAgentClient { /* private fields */ }Expand description
A connected kata-agent ttrpc client.
Thin wrapper around the real, generated
[protocols::agent_ttrpc_async::AgentServiceClient], scoped to the CRI
subset SandboxBackend::exec_sync needs: create → start → exec → wait
(+ drain stdout/stderr).
Implementations§
Source§impl KataAgentClient
impl KataAgentClient
Sourcepub async fn connect(address: &AgentAddress) -> Result<Self>
pub async fn connect(address: &AgentAddress) -> Result<Self>
Dial the agent at address (kata-agent’s well-known port 1024 unless
the caller has a reason to override it) and wrap it in an
AgentServiceClient.
pub async fn connect_with_port( address: &AgentAddress, port: u32, ) -> Result<Self>
Sourcepub fn from_ttrpc_client(client: Client) -> Self
pub fn from_ttrpc_client(client: Client) -> Self
Wrap an already-connected ttrpc::r#async::Client (used directly by
tests against a local mock server, and available to callers who
already have a connected client from elsewhere).
Sourcepub async fn create_container(
&self,
container_id: &str,
exec_id: &str,
argv: &[String],
rootfs: Option<&ContainerRootfs>,
) -> Result<()>
pub async fn create_container( &self, container_id: &str, exec_id: &str, argv: &[String], rootfs: Option<&ContainerRootfs>, ) -> Result<()>
CreateContainer — minimal OCI spec wired from container_id +
argv, plus (when rootfs is supplied) a virtio-fs Storage entry
that mounts the tenant VFS share as the container’s rootfs (#721).
When rootfs is None the spec’s Root.Path still points at
<CONTAINER_BASE>/<cid>/rootfs, but nothing is mounted there — the
guest must already have a rootfs at that path (the historical bare-VM
case, which fails CreateContainer with No such file or directory
precisely because it does not). Supplying rootfs is what makes the
tenant VFS be that rootfs; see ContainerRootfs / [rootfs_storage].
This is still NOT a full OCI bundle translation (no devices/volumes/
namespaces from PodSandbox) — just enough to boot a container whose
filesystem is the hyprstream tenant VFS.
pub async fn start_container(&self, container_id: &str) -> Result<()>
Sourcepub async fn exec_process(
&self,
container_id: &str,
exec_id: &str,
argv: &[String],
) -> Result<()>
pub async fn exec_process( &self, container_id: &str, exec_id: &str, argv: &[String], ) -> Result<()>
ExecProcess — run argv inside container_id under a fresh
exec_id. Does not block for completion; pair with Self::wait_process.
Sourcepub async fn wait_process(
&self,
container_id: &str,
exec_id: &str,
) -> Result<i32>
pub async fn wait_process( &self, container_id: &str, exec_id: &str, ) -> Result<i32>
WaitProcess — blocks (ttrpc-side) until the process exits, returning
its real terminal exit status from the guest agent.
Sourcepub async fn update_container(
&self,
container_id: &str,
resources: LinuxResources,
) -> Result<()>
pub async fn update_container( &self, container_id: &str, resources: LinuxResources, ) -> Result<()>
UpdateContainer — apply new cgroup resource limits to a running
container inside the guest.
This is the RPC a CRI UpdateContainerResources maps onto: the
kata-agent rewrites the container’s in-guest cgroups (CPU shares/quota/
period, memory limit, cpuset, …). It updates the container’s slice of
the existing VM; growing the VM itself past its boot size (vCPU /
memory hotplug) is a separate hypervisor concern and not attempted
here — matching upstream kata, whose update_container handler drives
the guest cgroup layer, with VM resize handled independently by the
runtime’s resource manager.
Sourcepub async fn stats_container(
&self,
container_id: &str,
) -> Result<StatsContainerResponse>
pub async fn stats_container( &self, container_id: &str, ) -> Result<StatsContainerResponse>
StatsContainer — fetch the guest cgroup (+ network) stats for a
container. The returned [agent::StatsContainerResponse] carries the
real in-guest cgroup counters (cgroup_stats.cpu_stats /
memory_stats); mapping them into the CRI ContainerStats shape is
the caller’s job (see KataBackend::container_stats).
Sourcepub async fn read_stdout_all(
&self,
container_id: &str,
exec_id: &str,
) -> Result<Vec<u8>>
pub async fn read_stdout_all( &self, container_id: &str, exec_id: &str, ) -> Result<Vec<u8>>
Drain available stdout via repeated ReadStdout calls until the
agent reports no more data (empty response).
pub async fn read_stderr_all( &self, container_id: &str, exec_id: &str, ) -> Result<Vec<u8>>
Sourcepub async fn exec(
&self,
container_id: &str,
argv: &[String],
timeout: Duration,
rootfs: Option<&ContainerRootfs>,
) -> Result<(i32, Vec<u8>, Vec<u8>)>
pub async fn exec( &self, container_id: &str, argv: &[String], timeout: Duration, rootfs: Option<&ContainerRootfs>, ) -> Result<(i32, Vec<u8>, Vec<u8>)>
Full ensure-container → exec → wait → drain sequence, matching the
(exit_code, stdout, stderr) shape SandboxBackend::exec_sync needs.
Calls Self::ensure_container first (create + start, idempotent)
so callers don’t need to separately track whether container_id has
already been created in this guest — matching the issue’s “real
CRI create/start/exec_sync” scope.
The returned i32 is WaitProcessResponse.status — a real terminal
exit value from the guest agent (see module docs re: #608/#610).
Auto Trait Implementations§
impl Freeze for KataAgentClient
impl RefUnwindSafe for KataAgentClient
impl Send for KataAgentClient
impl Sync for KataAgentClient
impl Unpin for KataAgentClient
impl UnsafeUnpin for KataAgentClient
impl UnwindSafe for KataAgentClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more