pub struct Ec2Runtime { /* private fields */ }Implementations§
Source§impl Ec2Runtime
impl Ec2Runtime
Sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Construct the Docker/Podman backend. Returns None when no container
CLI is available — callers then run in metadata-only mode.
Sourcepub async fn new_k8s(server_port: u16) -> Result<Self, BackendInitError>
pub async fn new_k8s(server_port: u16) -> Result<Self, BackendInitError>
Construct the Kubernetes backend. server_port is fakecloud’s bound
port (used when FAKECLOUD_K8S_SELF_URL omits one). Fails fast on
misconfiguration — never silently degrades to Docker.
Sourcepub fn firewall(&self) -> &FirewallEnforcer
pub fn firewall(&self) -> &FirewallEnforcer
The firewall enforcer, so the control plane can skip building the model when enforcement is disabled and report the mode for introspection.
Sourcepub async fn reconcile_firewall(&self, subnets: Vec<SubnetFirewall>)
pub async fn reconcile_firewall(&self, subnets: Vec<SubnetFirewall>)
Re-render and atomically apply the security-group/NACL ruleset for the given per-subnet model. No-op (cheap) when enforcement is disabled. Serialized against other reconciles (finding 4.3).
Sourcepub fn network_isolation_enforced(&self) -> bool
pub fn network_isolation_enforced(&self) -> bool
Whether this runtime backs network isolation with real enforcement — host nftables (Docker, opt-in) or k8s NetworkPolicy. Lets the control plane skip building the firewall model entirely when neither applies.
Sourcepub async fn reconcile_network_policies(&self, rules: Vec<InstanceRules>)
pub async fn reconcile_network_policies(&self, rules: Vec<InstanceRules>)
Apply one NetworkPolicy per instance for the k8s backend. No-op on the Docker backend (which uses nftables instead). Serialized against other reconciles so a concurrent apply+prune can’t delete a just-applied policy (finding 4.3).
Sourcepub fn network_isolation_summary(&self) -> NetworkIsolationSummary
pub fn network_isolation_summary(&self) -> NetworkIsolationSummary
A snapshot of how this runtime isolates instance traffic, for the
/_fakecloud/ec2/instance-networks introspection endpoint (#1745 ph5).
Sourcepub async fn run_instance(
&self,
instance_id: &str,
user_data: Option<&str>,
tags: &BTreeMap<String, String>,
network: Option<&InstanceNetwork>,
) -> Result<RunningInstance, RuntimeError>
pub async fn run_instance( &self, instance_id: &str, user_data: Option<&str>, tags: &BTreeMap<String, String>, network: Option<&InstanceNetwork>, ) -> Result<RunningInstance, RuntimeError>
Boot a container for an instance. user_data is the base64-encoded
user-data as received on the wire (RunInstances UserData), run at
boot the way cloud-init would, if present.
Sourcepub async fn stop_instance(&self, instance_id: &str)
pub async fn stop_instance(&self, instance_id: &str)
Stop an instance’s backing container (maps to StopInstances).
Docker stops the container in place; k8s deletes the Pod (recreated
on the next Start).
Sourcepub async fn start_instance(&self, instance_id: &str) -> Option<RunningInstance>
pub async fn start_instance(&self, instance_id: &str) -> Option<RunningInstance>
Start a previously-stopped instance (maps to StartInstances).
Returns the running container’s (possibly new) handle and private IP.
Docker starts the existing container; k8s recreates the Pod under a new
unique name, so the handle changes — callers should persist it.
Sourcepub async fn reboot_instance(
&self,
instance_id: &str,
) -> Option<RunningInstance>
pub async fn reboot_instance( &self, instance_id: &str, ) -> Option<RunningInstance>
Restart an instance’s backing container (maps to RebootInstances).
Docker restarts in place; k8s deletes and recreates the Pod under a new
name. Returns the running container’s handle + IP when it changed (k8s),
so callers can persist the new handle; None when nothing to update.
Sourcepub async fn terminate_instance(&self, instance_id: &str)
pub async fn terminate_instance(&self, instance_id: &str)
Remove an instance’s backing container (maps to TerminateInstances).
Sourcepub async fn stop_all(&self)
pub async fn stop_all(&self)
Tear down every container this runtime spawned (used on reset and shutdown). The Docker backend leans on the shared reaper for any container it loses track of.
Sourcepub async fn reap_stale(&self)
pub async fn reap_stale(&self)
Sweep instance Pods orphaned by a previous fakecloud process (k8s only; the Docker backend relies on the shared reaper).
Trait Implementations§
Source§impl Clone for Ec2Runtime
impl Clone for Ec2Runtime
Source§fn clone(&self) -> Ec2Runtime
fn clone(&self) -> Ec2Runtime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Ec2Runtime
impl !UnwindSafe for Ec2Runtime
impl Freeze for Ec2Runtime
impl Send for Ec2Runtime
impl Sync for Ec2Runtime
impl Unpin for Ec2Runtime
impl UnsafeUnpin for Ec2Runtime
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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