pub struct Controller { /* private fields */ }Expand description
The daemon’s stack controller.
Implementations§
Source§impl Controller
impl Controller
Sourcepub fn start(
client: Client,
store: Store,
interval: Duration,
secrets: Arc<Secrets>,
) -> Result<Controller>
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.
Sourcepub fn start_with(
client: Client,
store: Store,
interval: Duration,
secrets: Arc<Secrets>,
observer: Option<Arc<dyn Observer>>,
) -> Result<Controller>
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.
Sourcepub fn secret_changed(&self, org: &OrgId, name: &str) -> Vec<String>
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.
Sourcepub fn refresh_secret(&self, org: &OrgId, name: &str) -> Result<Refreshed>
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.
pub fn balancer(&self) -> &Balancer
Sourcepub fn events(&self, since: u64, limit: usize) -> (u64, Vec<Event>)
pub fn events(&self, since: u64, limit: usize) -> (u64, Vec<Event>)
Events after since (0: all kept), oldest first, at most limit.
Sourcepub fn wait_events(
&self,
since: u64,
limit: usize,
timeout: Duration,
) -> (u64, Vec<Event>)
pub fn wait_events( &self, since: u64, limit: usize, timeout: Duration, ) -> (u64, Vec<Event>)
Wait up to timeout for an event after since.
Sourcepub fn set_event_sink(&self, sink: EventSink)
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.
Sourcepub fn set_metrics_sink(&self, tx: SyncSender<Sample>)
pub fn set_metrics_sink(&self, tx: SyncSender<Sample>)
Send every metrics sample to tx too (the metrics history).
Sourcepub fn event(
&self,
kind: &str,
level: &str,
stack: &str,
service: &str,
message: String,
)
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.
Sourcepub fn relay(
&self,
kind: Option<&str>,
level: &str,
stack: &str,
service: &str,
instance: Option<&str>,
message: String,
)
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.
pub fn note(&self, level: &str, stack: &str, message: String)
Sourcepub fn note_service(
&self,
level: &str,
stack: &str,
service: &str,
message: String,
)
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.
Sourcepub fn service_event(
&self,
level: &str,
stack: &str,
service: &str,
message: String,
)
pub fn service_event( &self, level: &str, stack: &str, service: &str, message: String, )
Record an event about one service (stack qualified).
Sourcepub fn plan(&self, def: &StackDef) -> Result<Vec<DeployChange>>
pub fn plan(&self, def: &StackDef) -> Result<Vec<DeployChange>>
What deploying def would change, without deploying it.
pub fn client(&self) -> &Client
Sourcepub fn validate(&self, def: &StackDef) -> Result<()>
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).
Sourcepub fn deploy(&self, def: StackDef) -> Result<Vec<DeployChange>>
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.
Sourcepub fn org_limits_changed(&self, org: &OrgId) -> usize
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.
Sourcepub fn remove(&self, name: &str, volumes: bool, timeout: Duration) -> Result<()>
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).
Sourcepub fn rollback(&self, name: &str) -> Result<Vec<DeployChange>>
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).
Sourcepub fn scale(&self, name: &str, service: &str, replicas: u32) -> Result<()>
pub fn scale(&self, name: &str, service: &str, replicas: u32) -> Result<()>
Change one service’s replica count.
Sourcepub fn redeploy(&self, name: &str, service: &str) -> Result<()>
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.
Sourcepub fn definitions(&self) -> Vec<Arc<StackDef>>
pub fn definitions(&self) -> Vec<Arc<StackDef>>
Every stored definition, without computing status.
Sourcepub fn definition(&self, name: &str) -> Result<StackDef>
pub fn definition(&self, name: &str) -> Result<StackDef>
The stored definition of a stack.
pub fn list(&self) -> Vec<StackStatus>
pub fn status(&self, name: &str) -> Result<StackStatus>
Sourcepub fn logs(
&self,
name: &str,
service: &str,
slot: Option<u32>,
lines: usize,
) -> Result<BTreeMap<String, String>>
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).
Sourcepub fn last_failure(&self, name: &str, service: &str) -> Option<FailedAttempt>
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.