Run non-interactive sessions through production coordination

This commit is contained in:
ms2k 2026-07-16 16:28:18 +09:00
commit 71b0266cf2

View file

@ -17,7 +17,8 @@ use lazaret_storage_catalog::Catalog;
use crate::control::ControlSessionAdmission;
use crate::control::{
ControlError, PublishedControlFace, SessionRegistry, StagedControlFace, TrustAnchor,
ControlError, NonInteractiveSessionExecutor, PublishedControlFace, SessionRegistry,
StagedControlFace, TrustAnchor,
};
use crate::domain_store::HostCoordinatorDomainStore;
use crate::lifecycle::{
@ -39,6 +40,12 @@ impl fmt::Display for ProductionLifecycleError {
impl std::error::Error for ProductionLifecycleError {}
impl ProductionLifecycleError {
pub(crate) fn service(error: impl fmt::Display) -> Self {
Self(error.to_string())
}
}
fn failure(error: impl fmt::Display) -> ProductionLifecycleError {
ProductionLifecycleError(error.to_string())
}
@ -59,6 +66,7 @@ pub struct ProductionBootstrapPlan<'a> {
pub runtime_root: PathBuf,
pub bundle_digest: BundleDigest,
pub invoking_uid: u32,
pub non_interactive_executor: Arc<dyn NonInteractiveSessionExecutor>,
}
pub struct ProductionLifecycleAdapter<'a> {
@ -332,7 +340,7 @@ impl<'a> ProductionLifecycleAdapter<'a> {
.take()
.ok_or_else(|| ProductionLifecycleError("Trust Anchor is absent".into()))?;
self.staged_control = Some(
StagedControlFace::stage(
StagedControlFace::stage_with_executor(
path_from_host(
self.plan
.configuration
@ -343,6 +351,7 @@ impl<'a> ProductionLifecycleAdapter<'a> {
self.plan.invoking_uid,
anchor,
Arc::clone(&self.registry),
Arc::clone(&self.plan.non_interactive_executor),
)
.map_err(failure)?,
);
@ -507,10 +516,13 @@ pub fn serve_production_control(
.map_err(|error| ControlError::Lifecycle(error.to_string()))
},
|session_id| {
let mut lifecycle = lifecycle.lock().map_err(|_| ControlError::LockPoisoned)?;
lifecycle
.lock()
.map_err(|_| ControlError::LockPoisoned)?
.disconnect_session(session_id)
.map_err(|error| ControlError::Lifecycle(error.to_string()))?;
lifecycle
.teardown_if_idle()
.map(|_| ())
.map_err(|error| ControlError::Lifecycle(error.to_string()))
},
)