Integrate host escalation with production sessions
This commit is contained in:
parent
254bb37764
commit
696dae610a
1 changed files with 1175 additions and 96 deletions
|
|
@ -371,6 +371,56 @@ impl SessionPromptTransport {
|
|||
.map_err(|_| TerminalError::PromptValidation)?
|
||||
.remove(&session_id))
|
||||
}
|
||||
|
||||
pub(crate) fn begin_host_execution(&self, session_id: SessionId) -> Result<(), TerminalError> {
|
||||
self.transition_session(session_id, SessionPhase::HostExecuting)
|
||||
}
|
||||
|
||||
pub(crate) fn finish_escalation(&self, session_id: SessionId) -> Result<(), TerminalError> {
|
||||
self.pending
|
||||
.lock()
|
||||
.map_err(|_| TerminalError::PromptValidation)?
|
||||
.remove(&session_id);
|
||||
self.routed
|
||||
.lock()
|
||||
.map_err(|_| TerminalError::PromptValidation)?
|
||||
.remove(&session_id);
|
||||
let snapshot = self.store.snapshot()?;
|
||||
let Some(session) = snapshot
|
||||
.sessions
|
||||
.iter()
|
||||
.find(|session| session.session_id == session_id)
|
||||
else {
|
||||
return Err(TerminalError::UnknownSession);
|
||||
};
|
||||
match session.session_phase {
|
||||
SessionPhase::Attached => return Ok(()),
|
||||
SessionPhase::Prompting | SessionPhase::HostExecuting => {}
|
||||
SessionPhase::New
|
||||
| SessionPhase::Waiting
|
||||
| SessionPhase::Registering
|
||||
| SessionPhase::Closed
|
||||
| SessionPhase::Failed => return Err(TerminalError::InactiveRoute),
|
||||
}
|
||||
self.transition_session(session_id, SessionPhase::Attached)
|
||||
}
|
||||
|
||||
fn transition_session(
|
||||
&self,
|
||||
session_id: SessionId,
|
||||
session_phase: SessionPhase,
|
||||
) -> Result<(), TerminalError> {
|
||||
let snapshot = self.store.snapshot()?;
|
||||
let mut session = snapshot
|
||||
.sessions
|
||||
.into_iter()
|
||||
.find(|session| session.session_id == session_id)
|
||||
.ok_or(TerminalError::UnknownSession)?;
|
||||
session.session_phase = session_phase;
|
||||
self.store
|
||||
.apply(&[DomainStoreMutation::PutSession(session)])?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl PromptRouteCancellation for SessionPromptTransport {
|
||||
|
|
@ -1427,6 +1477,11 @@ impl SessionTerminalFactory for RunscSessionTerminalFactory {
|
|||
"-internal-pid-file={}",
|
||||
request.internal_pid_file.display()
|
||||
))
|
||||
.argument("-env")
|
||||
.argument(format!(
|
||||
"LAZARET_SESSION_ID={}",
|
||||
hex_lower(request.session_id.as_bytes())
|
||||
))
|
||||
.argument(hex_lower(request.container_id.as_bytes()))
|
||||
.argument(SANDBOX_INIT_PATH)
|
||||
.argument(PRIVATE_SESSION_EXEC_ROLE)
|
||||
|
|
|
|||
Loading…
Reference in a new issue