pub struct Controller { /* private fields */ }Expand description
The daemon’s stack controller.
Implementations§
Source§impl Controller
impl Controller
Sourcepub fn set_dns_scope(&self, f: DnsScopeFn)
pub fn set_dns_scope(&self, f: DnsScopeFn)
Name services in their stack’s project environment too, as f
says (the apps’ compose ownership). Each worker asks on its next
pass and rewrites its hosts file when the answer changed.
Sourcepub fn republish_dns(&self, org: &OrgId)
pub fn republish_dns(&self, org: &OrgId)
Something Controller::set_dns_scope’s answer depends on changed
in org (a stack joined or left a project environment): wake the
org’s workers, so their names follow now rather than on their next
pass.
Source§impl Controller
impl Controller
Sourcepub fn secret_changed(&self, org: &OrgId, name: &str) -> Vec<Cycle>
pub fn secret_changed(&self, org: &OrgId, name: &str) -> Vec<Cycle>
A stored secret got a new value (isb secret set): every stack in
the org bound to it moves to the new version, and each service using
it rolls, restarts in place or is left stale, per its on_change.
Returns what happened, per service.
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): once per driver, however many stacks use it.
Returns each driver and version found, and what the new version did.
Sourcepub fn rotate_before_set(
&self,
org: &OrgId,
name: &str,
value: &[u8],
) -> Result<Vec<Applied>>
pub fn rotate_before_set( &self, org: &OrgId, name: &str, value: &[u8], ) -> Result<Vec<Applied>>
isb secret set NAME, before the value is stored: run the rotate
command of every stack secret bound to name in the org, with the
new value, so it takes effect where the old one is kept (a database
user’s password) before any replica is given it. The first failure
is the answer, and the caller stores nothing.
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.
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 resume_from(&self, since: u64) -> u64
pub fn resume_from(&self, since: u64) -> u64
A client’s resume cursor for Self::events: one past the newest
event came from an earlier process (numbering restarts with the
daemon), so the client starts over from what is kept instead of
waiting for this feed to count back up to it.
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) and name its widest slot.
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,
always: bool,
) -> Option<FailedAttempt>
pub fn last_failure( &self, name: &str, service: &str, always: bool, ) -> Option<FailedAttempt>
The last replica of a service that failed to come up, with its
output, while the service is not converged (or always): after the
instance is deleted, this is all that is left to read.
Sourcepub fn failed_attempts(&self, name: &str) -> BTreeMap<String, FailedAttempt>
pub fn failed_attempts(&self, name: &str) -> BTreeMap<String, FailedAttempt>
The last failed attempt of each of a stack’s services, converged or not.