Require fresh State Anchor absence before lease release
This commit is contained in:
parent
4dd2b150d2
commit
3b76b59bdf
1 changed files with 543 additions and 194 deletions
|
|
@ -30,6 +30,14 @@ use crate::network::{NetworkCoordinator, NetworkCoordinatorError};
|
|||
|
||||
const SUPERVISOR_EXIT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct StateAnchorAbsenceObservation {
|
||||
pub user_namespace: NamespaceIdentity,
|
||||
pub mount_namespace: NamespaceIdentity,
|
||||
pub mount: MountIdentity,
|
||||
pub observed: MountIdentity,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum SandboxCoordinatorError {
|
||||
Store(DomainStoreError),
|
||||
|
|
@ -967,6 +975,45 @@ impl CommittedSandboxRuntime {
|
|||
}
|
||||
}
|
||||
|
||||
/// Requests a fresh namespace-local observation of exact State Anchor absence.
|
||||
///
|
||||
/// # Errors
|
||||
/// Refuses an RS refusal, echoed mount, mismatched authority, or channel failure.
|
||||
pub fn observe_state_anchor_absence(
|
||||
&mut self,
|
||||
user_namespace: NamespaceIdentity,
|
||||
mount_namespace: NamespaceIdentity,
|
||||
mount: MountIdentity,
|
||||
) -> Result<StateAnchorAbsenceObservation, SandboxCoordinatorError> {
|
||||
self.control
|
||||
.observe_state_anchor_absence(user_namespace, mount_namespace, mount)?;
|
||||
match self.control.receive()? {
|
||||
SupervisorEvent::StateAnchorAbsenceObserved {
|
||||
user_namespace: observed_user_namespace,
|
||||
mount_namespace: observed_mount_namespace,
|
||||
mount: observed_mount,
|
||||
observed,
|
||||
} if observed_user_namespace == user_namespace
|
||||
&& observed_mount_namespace == mount_namespace
|
||||
&& observed_mount == mount
|
||||
&& observed != mount =>
|
||||
{
|
||||
Ok(StateAnchorAbsenceObservation {
|
||||
user_namespace: observed_user_namespace,
|
||||
mount_namespace: observed_mount_namespace,
|
||||
mount: observed_mount,
|
||||
observed,
|
||||
})
|
||||
}
|
||||
SupervisorEvent::Refused(detail) => {
|
||||
Err(SandboxCoordinatorError::Io(io::Error::other(detail)))
|
||||
}
|
||||
_ => Err(SandboxCoordinatorError::InvalidState(
|
||||
"Runtime Supervisor did not provide exact State Anchor absence evidence",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Gracefully exits and reaps the resource-empty exact Runtime Supervisor.
|
||||
///
|
||||
/// # Errors
|
||||
|
|
|
|||
Loading…
Reference in a new issue