Skip to main content

Running

Struct Running 

Source
pub struct Running<'r> { /* private fields */ }
Expand description

A run: a manifest under a name, on a runner.

Implementations§

Source§

impl Running<'_>

Source

pub async fn attach( &self, pick: AccessPick<'_>, opts: &RunOptions, events: &dyn Events, ) -> Result<AttachReport>

Hot-adds the run’s on-demand access machine into the running run, with opts (the params and secrets the run’s operations take), brought up with the user-picked image (its baked default otherwise), on network when given. image is a container image for a Compose access service, the Vagrant box for an access VM. machine names which on-demand machine, needed only when the run has more than one. network is one of the manifest’s networks: a Compose access service’s container also joins it, by the native name the run gives it (as status shows it); a VM’s networks are its Vagrantfile’s, so a Vagrant run refuses one.

§Errors

Fails with machine_unknown for a named machine the run doesn’t have, machine_ambiguous when it has several and none is named, network_unknown for a network it doesn’t have, unsupported when it declares no access machine (or the target brings none up later: a server or a cloud) and for a network it can’t join (a Vagrant run’s), not_running when the run isn’t up, tool_failed when the container can’t join the network (one already on it has), and as the other operations do for a step or the state.

Source

pub async fn detach( &self, machine: Option<&str>, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Hot-removes the run’s access machine from the running run, with opts, leaving the rest up: the on-demand machine chosen as Running::attach chooses it, taken out as Running::retire takes a machine out (its Compose service removed through the access profile, its VM destroyed).

§Errors

Fails as Running::attach does for the machine choice and the target, and as the other operations do for a step or the state.

Source§

impl Running<'_>

Source

pub fn console_command( &self, machine: &str, user: Option<&str>, ) -> Result<ShellCommand>

The command that opens an interactive console into machine, any machine of the run (an SSH login on a cloud’s), by its native name (the Compose service, the Vagrant define), so the embedder never reconstructs a container name. A query: it runs nothing, emits nothing, writes only what the command needs (the SSH configuration in the run’s state folder, for a way in over SSH; nothing for a container’s), and doesn’t check the machine is up (the embedder runs what it returns in its own terminal once the machine is up or attached).

With user, the console opens as that account of the machine, in its home, rather than as the account the way in logs in as (a container’s own user, Vagrant’s vagrant, a module’s SSH user): exec --user into a container, a sudo -i login on a VM (its way in’s account may sudo, as a Vagrant box’s and a cloud image’s do). The machine must have the account.

§Errors

Fails with machine_unknown for a machine the run doesn’t have, not_running when the run gives it no address yet, and unsupported where the target has no way in yet, for a user that can’t name an account, and for a user on a Windows machine.

Source§

impl Running<'_>

Source

pub async fn down(&self, opts: &RunOptions, events: &dyn Events) -> Result<()>

Removes everything the run created, through its down steps: containers, networks and volumes, VMs, a module’s resources.

§Errors

Fails, after its error event, when the run is recorded elsewhere, a down step fails, or the run’s state can’t be locked or written.

Source

pub async fn park( &self, mode: Park, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Stops the run, keeping what it created, with the manifest’s park steps for mode; opts as the other operations take them (the place the run is on, the params and secrets its steps read). Its SSH goes through the jump the run recorded at up.

§Errors

Fails with not_parkable when the manifest has no steps for mode, with not_running when nothing of the run is there, and as Running::down does for a run recorded elsewhere, a step or the state.

Source

pub async fn resume( &self, opts: &RunOptions, events: &dyn Events, ) -> Result<Started>

Starts a parked run again, as it was: nothing is re-created, so inputs aren’t needed again.

§Errors

Fails with nothing_to_resume when nothing is left (the parked mark is dropped) or a member machine is gone (removed outside the runner: the run is then recorded failed, so the next up clears what is left and starts it afresh), and as Running::up does for a tool, a step, a ready condition or the state.

Source

pub async fn check( &self, opts: &RunOptions, events: &dyn Events, ) -> Result<CheckReport>

Runs the run’s checks against the running run.

§Errors

Fails with not_running when no member machine runs, and when a setup or teardown step fails. A failing check isn’t an error: the report says it (ok: false).

Source

pub async fn provision( &self, machine: Option<&str>, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Runs the run’s set-up again on its running machines, every one or machine (a run machine of the manifest), without rebuilding them: the manifest’s provision steps. The values given at launch aren’t kept by the runner: pass them again in opts.

§Errors

Fails with machine_unknown for a machine the run doesn’t have, not_running when no member machine runs, unsupported when the manifest has no provision steps, and as Running::up does for a step or the state.

Source§

impl Running<'_>

Source

pub async fn graphical_console(&self, machine: &str) -> Result<Console>

machine’s graphical console (its screen), as its manifest says it has one under the run’s provider (machines[].consoles): its protocol (VNC or RDP), where it answers (crate::Endpoint: a port of this computer’s loopback, or Proxmox’s VNC websocket), the account and password that sign in. A console the hypervisor says listens anywhere but the loopback is refused, and so is one on the loopback that doesn’t answer. A console reached through an SSH tunnel holds it open: drop it once the viewer is done. Emits nothing, never locks the run, and writes no state but a Proxmox request’s credentials while curl reads them. While an operation holds the run, the machine is as the runner last read it: the hypervisor is asked where its console is all the same.

§Errors

machine_unknown for a machine the run doesn’t have; no_console when it has none there (the error says why, in the manifest’s words: UTM’s SPICE, VirtualBox without its extension pack…), isn’t running, another process acts on it (Vagrant’s lock: its start or its provisioning), its hypervisor doesn’t say where its console is or started it without one, it doesn’t answer there, or the runner chose none for it yet (VMware’s: the run’s next start chooses it); a tool’s own failure (tool_missing for a missing virsh, VBoxManage, curl or ssh).

Source

pub async fn native_console(&self, machine: &str) -> Result<NativeConsole>

What opens running VM machine in its hypervisor’s own app, beside the embedder’s viewer (crate::Status::native names the app): a program and its arguments, a macOS app and what it opens, or an https URL, best first, each argument checked; the embedder runs the first this computer has, never through a shell. Reads as Running::graphical_console does, and runs nothing but a read (Parallels’ prlctl, libvirt’s virsh).

§Errors

machine_unknown for a machine the run doesn’t have; no_console when its hypervisor has no app (vagrant-qemu), it isn’t a VM, isn’t running, another process acts on it, or what names it can’t be handed to the app as it is.

Source§

impl Running<'_>

Source

pub async fn retire( &self, machine: &str, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Takes machine machine out of the running run, ahead of its removal from the manifest (then an update), or of its move out of the run’s start (back to an on-demand machine): what the next update wouldn’t remove itself. A Vagrant VM is destroyed (Vagrant forgets a define the Vagrantfile no longer has); a Compose service is stopped and removed with the services in its namespace, on this computer or inside the run’s VM (an update leaves a service outside the default start running). A machine a Terraform module makes is left to the update’s apply, which removes what the module no longer makes: the retire runs nothing and succeeds.

§Errors

Fails with machine_unknown for a machine the run doesn’t have; unsupported for the VM the run’s containers run in (docker-vm’s guest: every container would go with it), and for a machine the run has nothing to take out of (one whose manifest doesn’t say how it runs, a Compose service with no VM to run in, an on-demand machine on a server or cloud); and as the other operations do for a step or the run’s state.

Source§

impl Running<'_>

Source

pub async fn up( &self, opts: &RunOptions, events: &dyn Events, ) -> Result<Started>

Starts the run: refused while it runs or runs elsewhere; a parked run is resumed (with Occupied::ResumeParked); leftovers are removed first.

§Errors

Fails, after its error event, when the run is up already (already_running) or recorded elsewhere (running_elsewhere); when a param, secret or tool is missing or refused; when a host port is taken (port_in_use); when a step fails or runs out of time (tool_failed, tool_missing, timeout); when a ready condition doesn’t hold (not_ready); or when the run’s state can’t be locked or written (locked, io).

Source§

impl Running<'_>

Source

pub async fn update( &self, opts: &RunOptions, events: &dyn Events, ) -> Result<Started>

Brings the running run up to date with its manifest (see the module doc): up‘s steps again, with the run’s recorded params and opts’ secrets, then what follows up.

§Errors

Fails with not_running when no member machine runs, when a secret or tool is missing, and as up does for a step, a ready condition or the run’s state.

Source§

impl<'r> Running<'r>

Source

pub fn with_connection(self, secrets: Secrets) -> Running<'r>

The run with secrets, the values of its connection slots (an ESXi host’s password), delivered to every operation, status (which takes no options) too. Kept in memory only, never stored; a value an operation’s options give wins.

Source

pub fn manifest(&self) -> &Manifest

The manifest.

Source

pub fn name(&self) -> &RunName

The run’s name.

Source

pub async fn status(&self) -> Result<Status>

The run as it stands: never locked, and never an event. It changes nothing of the run, but readies its state folder as an operation does for the tools it asks (the folder; Compose’s empty pinned-ports file, which every Compose call names; Terraform’s plugin cache); it never writes a secret (the consoles the runner chooses are an operation’s to choose). While an operation holds the run (this runner’s, or another process’s), the engine isn’t asked: that operation acts on the run with the same tools, which may refuse a read until it is done (Vagrant locks each VM for the whole of a vagrant up, provisioning included). The status is then the operation’s state, with the machines as last read (Status::live false).

§Errors

Fails when the engine can’t be asked (the status step fails or runs out of time) or the run’s record can’t be read. Another process acting on a machine (Vagrant’s lock on it, past a short wait) is no failure: that machine is MachineState::Busy, the others as last read, and the status isn’t live.

Trait Implementations§

Source§

impl Debug for Running<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'r> !RefUnwindSafe for Running<'r>

§

impl<'r> !UnwindSafe for Running<'r>

§

impl<'r> Forget for Running<'r>

§

impl<'r> Freeze for Running<'r>

§

impl<'r> Move for Running<'r>

§

impl<'r> Send for Running<'r>

§

impl<'r> Sync for Running<'r>

§

impl<'r> Unpin for Running<'r>

§

impl<'r> UnsafeUnpin for Running<'r>

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.

Source§

impl<T> Instrument for T

Source§

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

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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