fix: evict finished reconstitute sessions, keep the mTLS listener alive on accept errors, drop dead code

Also removes OperatorActor.browser, unused since reconstitute targets are confined for every caller.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 21:19:58 +07:00
parent 6d2b882b3d
commit d14b27669a
3 changed files with 26 additions and 6 deletions

View File

@@ -251,7 +251,6 @@ struct ReconstituteStartResponse {
pub(super) struct OperatorActor {
/// Display only. Never record this as "who did it": an IdP can call a user anything.
pub(super) name: String,
pub(super) browser: bool,
pub(super) principal: Principal,
pub(super) subject: Subject,
pub(super) request_id: Uuid,
@@ -318,7 +317,6 @@ fn authenticate_inner(
) -> Result<OperatorActor, StatusCode> {
let configured_admin = |name: &str, principal: Principal| OperatorActor {
name: name.into(),
browser: false,
principal,
subject: Subject {
user_id: None,
@@ -351,7 +349,6 @@ fn authenticate_inner(
principal: session.principal(),
subject: session.subject(),
name: session.actor,
browser: true,
request_id,
});
}
@@ -860,6 +857,7 @@ async fn start_reconstitute(
let mut map = state_bg.reconstitute_sessions.write().await;
if let Some(s) = map.get_mut(&session_id) {
if s.state == ReconstituteState::Aborted {
evict_reconstitute_later(&state_bg, session_id);
return;
}
s.seconds_remaining = remaining;
@@ -873,6 +871,7 @@ async fn start_reconstitute(
return;
};
if s.state == ReconstituteState::Aborted {
evict_reconstitute_later(&state_bg, session_id);
return;
}
s.state = ReconstituteState::Restoring;
@@ -891,6 +890,7 @@ async fn start_reconstitute(
.db
.audit("reconstitute.done", &format!("session={session_id}"))
.await;
evict_reconstitute_later(&state_bg, session_id);
});
Ok(Json(ReconstituteStartResponse {
@@ -899,6 +899,19 @@ async fn start_reconstitute(
}))
}
/// How long a finished restore session stays readable before its entry is dropped.
const RECONSTITUTE_RETAIN: std::time::Duration = std::time::Duration::from_secs(3600);
/// Drops a finished session from the in-memory map after `RECONSTITUTE_RETAIN`, so the map does
/// not grow for as long as the hub runs.
fn evict_reconstitute_later(state: &HubState, id: Uuid) {
let state = state.clone();
tokio::spawn(async move {
tokio::time::sleep(RECONSTITUTE_RETAIN).await;
state.reconstitute_sessions.write().await.remove(&id);
});
}
fn browser_export_path(
state: &HubState,
requested: &str,