swarm-controller: a stop signal ends the startup secret-store reads
The queue client secret and the webhook secret are read at start through a retry schedule of about a minute. Neither heard SIGTERM, because the shutdown signal was only installed once the controller began serving, so a stop during a store outage waited out the schedule or the unit's stop timeout. main installs the signal first and passes it to queue_identity::init and webhook::load. A stop that arrives first ends the read and exits 0.
This commit is contained in:
parent
7df2d646ff
commit
96cb25a040
1 changed files with 131 additions and 20 deletions
|
|
@ -111,7 +111,7 @@ use startup::{
|
|||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
hive_log::init();
|
||||
swarm_secret_client::install_crypto_provider();
|
||||
let stop = install_process_hooks();
|
||||
|
||||
let path = socket_path();
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ async fn main() -> Result<()> {
|
|||
|
||||
// Before every user of the identity: the queue, the bridge and both OTLP
|
||||
// exporters read it from `queue_identity::get`.
|
||||
queue_identity::init().await?;
|
||||
exit_if_stopped(queue_identity::init(stop.clone()).await?);
|
||||
let status = connect_status_reader().await?;
|
||||
|
||||
// Same "not fatal, log and carry on" shape as the queue connect above:
|
||||
|
|
@ -202,7 +202,7 @@ async fn main() -> Result<()> {
|
|||
register_cert_gauges(jobq_metrics_provider.as_ref());
|
||||
held_deploys::register(jobq_metrics_provider.as_ref(), &jobq);
|
||||
|
||||
let webhook_secret = webhook::load().await;
|
||||
let webhook_secret = exit_if_stopped(webhook::load(stop.clone()).await);
|
||||
|
||||
// Diagnostic only — `put_matrix_account` does not call this yet (see its
|
||||
// own doc comment), so this cannot change any request's outcome. Logged
|
||||
|
|
@ -269,7 +269,21 @@ async fn main() -> Result<()> {
|
|||
reviews: Arc::default(),
|
||||
alerts: alerts::from_env(),
|
||||
};
|
||||
serve(listener, state, swarm_secret_client::shutdown_signal()).await
|
||||
serve(listener, state, stop).await
|
||||
}
|
||||
|
||||
/// The TLS provider, and the stop signal. The signal is installed first thing,
|
||||
/// so a stop that arrives while the startup reads wait on a store that is down
|
||||
/// ends them instead of being ignored until `serve`.
|
||||
fn install_process_hooks() -> swarm_secret_client::Shutdown {
|
||||
swarm_secret_client::install_crypto_provider();
|
||||
swarm_secret_client::shutdown_signal()
|
||||
}
|
||||
|
||||
/// The value a startup step produced, or exit 0 when the stop signal ended the
|
||||
/// step first: nothing is serving yet, so there is nothing to drain.
|
||||
fn exit_if_stopped<T>(started: Option<T>) -> T {
|
||||
started.unwrap_or_else(|| std::process::exit(0))
|
||||
}
|
||||
|
||||
/// Registers the `bao.client_cert.*` gauges for the controller's own store
|
||||
|
|
|
|||
Loading…
Reference in a new issue