[control] Fix round 1: changes apply while Caddy serves (admin socket, watch through Caddy), revocations that fail are errors and catch up, proof only on the forward-auth UI host, root keys found by content, intermediates checked before install, stale SNI cleared before each handshake
This commit is contained in:
@@ -233,18 +233,9 @@ pub async fn overview(
|
||||
intermediate: super::pki::intermediate_view(c),
|
||||
site,
|
||||
paused_reason: c.effective_pause().map(|p| p.code),
|
||||
paused: c.effective_pause().map(|p| {
|
||||
if p.code == "engine.caddy" {
|
||||
Blocked {
|
||||
code: p.code,
|
||||
message: p.message,
|
||||
}
|
||||
} else {
|
||||
Blocked {
|
||||
code: "control.paused".into(),
|
||||
message: message("control.paused", &messages::params([("reason", p.message)])),
|
||||
}
|
||||
}
|
||||
paused: c.effective_pause().map(|p| Blocked {
|
||||
code: "control.paused".into(),
|
||||
message: message("control.paused", &messages::params([("reason", p.message)])),
|
||||
}),
|
||||
// Under Caddy, health is not read (edge is stopped); the chip says Caddy serves.
|
||||
health_error: error
|
||||
|
||||
@@ -252,6 +252,9 @@ pub struct CertsView {
|
||||
pub approval: String,
|
||||
/// Open device requests.
|
||||
pub requests: Vec<PkiRequestView>,
|
||||
/// Set while the device list is not in force (could not be written or handed to the
|
||||
/// proxy); Ianitor retries every few seconds.
|
||||
pub devices_problem: Option<Blocked>,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- handlers
|
||||
@@ -288,6 +291,15 @@ pub async fn get_certs(State(st): Shared) -> Result<Response, ApiError> {
|
||||
.map(|p| p.approval.clone())
|
||||
.unwrap_or_default(),
|
||||
requests,
|
||||
devices_problem: c
|
||||
.devices_problem
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|p| p.clone())
|
||||
.map(|_| Blocked {
|
||||
code: "pki.devices_unwritten".into(),
|
||||
message: message("pki.devices_unwritten", &Params::new()),
|
||||
}),
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
@@ -480,7 +492,16 @@ pub async fn revoke_device(
|
||||
})
|
||||
.await?;
|
||||
log::info!(target: "ianitor::pki", "device {} revoked by {}", d.id, actor.token_id);
|
||||
st.ctl.devices_changed().await;
|
||||
// The revocation is recorded; it is in force only once the engines have the new list.
|
||||
if let Err(e) = st.ctl.devices_changed().await {
|
||||
let mut err = ApiError::new(
|
||||
StatusCode::SERVICE_UNAVAILABLE,
|
||||
"pki.devices_unwritten",
|
||||
Params::new(),
|
||||
);
|
||||
err.body.detail = Some(e);
|
||||
return Err(err);
|
||||
}
|
||||
Ok(StatusCode::NO_CONTENT.into_response())
|
||||
}
|
||||
|
||||
@@ -648,7 +669,7 @@ pub struct EngineSwitchView {
|
||||
pub fn engine_view(c: &Control) -> EngineSwitchView {
|
||||
let e = c.engine_state();
|
||||
let notes = if e.running == "caddy" {
|
||||
["engine.caddy", "share.engine_caddy"]
|
||||
["share.engine_caddy"]
|
||||
.iter()
|
||||
.map(|code| Blocked {
|
||||
code: (*code).into(),
|
||||
|
||||
@@ -531,7 +531,7 @@ pub struct Overview {
|
||||
pub site: Option<SiteView>,
|
||||
pub paused: Option<Blocked>,
|
||||
/// Why changes are paused: the underlying code (`apply.needs_attention`, `control.files_unwritten`,
|
||||
/// `repo.unreadable`, `engine.caddy`, …), so the UI can offer the right action.
|
||||
/// `repo.unreadable`, …), so the UI can offer the right action.
|
||||
pub paused_reason: Option<String>,
|
||||
/// Set when control cannot read health from edge (`health.unavailable`).
|
||||
pub health_error: Option<Blocked>,
|
||||
|
||||
Reference in New Issue
Block a user