Skip to main content

Controller

Struct Controller 

Source
pub struct Controller { /* private fields */ }
Expand description

The daemon’s stack controller.

Implementations§

Source§

impl Controller

Source

pub fn start( client: Client, store: Store, interval: Duration, secrets: Arc<Secrets>, ) -> Result<Controller>

Load every stored stack and start reconciling it. Secret values are read from secrets whenever they are delivered.

Source

pub fn start_with( client: Client, store: Store, interval: Duration, secrets: Arc<Secrets>, observer: Option<Arc<dyn Observer>>, ) -> Result<Controller>

Controller::start, telling observer about rotation changes from the first one on.

Source

pub fn secret_changed(&self, org: &OrgId, name: &str) -> Vec<String>

A stored secret got a new value (isb secret set): every stack in the org bound to it moves to the new version and rolls. Returns the stacks rolled.

Source

pub fn refresh_secret(&self, org: &OrgId, name: &str) -> Result<Refreshed>

Re-read every binding to name in the org from its driver now (isb secret refresh). Returns each driver and version found, and the stacks rolled.

Source

pub fn balancer(&self) -> &Balancer

Source

pub fn events(&self, since: u64, limit: usize) -> (u64, Vec<Event>)

Events after since (0: all kept), oldest first, at most limit.

Source

pub fn wait_events( &self, since: u64, limit: usize, timeout: Duration, ) -> (u64, Vec<Event>)

Wait up to timeout for an event after since.

Source

pub fn set_event_sink(&self, sink: EventSink)

Hand every event to sink too (the persistent history), starting with the ones already kept, so none emitted before it was set is missed and none is handed over twice.

Source

pub fn set_metrics_sink(&self, tx: SyncSender<Sample>)

Send every metrics sample to tx too (the metrics history).

Source

pub fn snapshot(&self) -> Snapshot

The latest metrics sample.

Source

pub fn event( &self, kind: &str, level: &str, stack: &str, service: &str, message: String, )

Record an event from outside a worker (a deploy, a removal). Record an event of a known kind (Event::kind) about a stack, or one of its services when service is not empty.

Source

pub fn relay( &self, kind: Option<&str>, level: &str, stack: &str, service: &str, instance: Option<&str>, message: String, )

Re-emit an event another daemon recorded (a control plane mirroring a server’s feed), under this feed’s numbering.

Source

pub fn note(&self, level: &str, stack: &str, message: String)

Source

pub fn note_service( &self, level: &str, stack: &str, service: &str, message: String, )

Record an event about one service of a stack (an app’s deployment log, say). Not echoed to stderr: it can be chatty.

Source

pub fn service_event( &self, level: &str, stack: &str, service: &str, message: String, )

Record an event about one service (stack qualified).

Source

pub fn plan(&self, def: &StackDef) -> Result<Vec<DeployChange>>

What deploying def would change, without deploying it.

Source

pub fn client(&self) -> &Client

Source

pub fn validate(&self, def: &StackDef) -> Result<()>

Check a stack definition against this host without deploying it: every service must resolve (image source, paths, ports).

Source

pub fn deploy(&self, def: StackDef) -> Result<Vec<DeployChange>>

Deploy (or update) a stack. Returns what will change; the rollout itself happens in the background.

Source

pub fn org_limits_changed(&self, org: &OrgId) -> usize

An org’s limits changed: services of the org that are failing on a limit (a quota refusal from incus) retry now instead of after their backoff. Returns how many were woken.

Source

pub fn remove(&self, name: &str, volumes: bool, timeout: Duration) -> Result<()>

Remove a stack: every instance and published port; with volumes, its named volumes too. Returns once the workers have cleaned up (or after timeout).

Source

pub fn rollback(&self, name: &str) -> Result<Vec<DeployChange>>

Go back to the previous deployment (the current one becomes the previous, so a second rollback undoes the first).

Source

pub fn scale(&self, name: &str, service: &str, replicas: u32) -> Result<()>

Change one service’s replica count.

Source

pub fn redeploy(&self, name: &str, service: &str) -> Result<()>

Replace every instance of a service even though its spec is the same (docker service update --force): picks up a moved image tag or a changed bind-mounted file.

Source

pub fn definitions(&self) -> Vec<Arc<StackDef>>

Every stored definition, without computing status.

Source

pub fn definition(&self, name: &str) -> Result<StackDef>

The stored definition of a stack.

Source

pub fn list(&self) -> Vec<StackStatus>

Source

pub fn status(&self, name: &str) -> Result<StackStatus>

Source

pub fn logs( &self, name: &str, service: &str, slot: Option<u32>, lines: usize, ) -> Result<BTreeMap<String, String>>

Recent output of a service’s replicas (or one slot’s).

Source

pub fn last_failure(&self, name: &str, service: &str) -> Option<FailedAttempt>

The last replica of a service that failed to come up, with its output, while the service is not converged: after the instance is deleted, this is all that is left to read.

Source

pub fn shutdown(&self)

Stop every worker and the balancer. Apps keep running in their instances; published ports stop until the next start.

Trait Implementations§

Source§

impl Clone for Controller

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V