Skip to main content

KataAgentClient

Struct KataAgentClient 

Source
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

Source

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.

Source

pub async fn connect_with_port( address: &AgentAddress, port: u32, ) -> Result<Self>

Source

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).

Source

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.

Source

pub async fn start_container(&self, container_id: &str) -> Result<()>

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

pub async fn read_stderr_all( &self, container_id: &str, exec_id: &str, ) -> Result<Vec<u8>>

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,