Fail teardown when control withdrawal fails
This commit is contained in:
parent
da7557b850
commit
a9c9cf7ab3
1 changed files with 51 additions and 11 deletions
|
|
@ -22,7 +22,7 @@ use lazaret_host_coordinator::control::{
|
|||
};
|
||||
use lazaret_host_coordinator::domain_store::{DomainStoreMutation, HostCoordinatorDomainStore};
|
||||
use lazaret_host_coordinator::lifecycle::{
|
||||
HostCoordinatorLifecycle, LifecycleAction, LifecycleAdapter,
|
||||
DomainPhase, HostCoordinatorLifecycle, LifecycleAction, LifecycleAdapter,
|
||||
};
|
||||
use lazaret_linux::filesystem::try_exclusive_flock;
|
||||
use rustix::process::getuid;
|
||||
|
|
@ -44,10 +44,12 @@ impl LifecycleAdapter for ControlLifecycleAdapter {
|
|||
action: LifecycleAction,
|
||||
_generation: &Generation,
|
||||
) -> Result<(), Self::Error> {
|
||||
if action == LifecycleAction::BeginTeardown
|
||||
&& let Some(face) = self.publication.lock().unwrap().take()
|
||||
{
|
||||
face.withdraw();
|
||||
if action == LifecycleAction::BeginTeardown {
|
||||
let mut publication = self.publication.lock().unwrap();
|
||||
if let Some(face) = publication.as_ref() {
|
||||
face.withdraw()?;
|
||||
}
|
||||
publication.take();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -861,7 +863,16 @@ fn coordinated_control_session_tracks_lifecycle_and_withdraws_before_teardown()
|
|||
Some(SessionPhase::Closed)
|
||||
);
|
||||
assert!(lifecycle.is_teardown_ready());
|
||||
std::fs::set_permissions(&directory.0, std::fs::Permissions::from_mode(0o500)).unwrap();
|
||||
assert!(lifecycle.begin_teardown().is_err());
|
||||
assert_eq!(lifecycle.phase(), DomainPhase::Ready);
|
||||
assert!(lifecycle.is_published());
|
||||
assert!(face.socket_path().exists());
|
||||
assert!(face.identity_path().exists());
|
||||
std::fs::set_permissions(&directory.0, std::fs::Permissions::from_mode(0o700)).unwrap();
|
||||
lifecycle.begin_teardown().unwrap();
|
||||
assert_eq!(lifecycle.phase(), DomainPhase::Stopping);
|
||||
assert!(!lifecycle.is_published());
|
||||
assert!(!face.socket_path().exists());
|
||||
assert!(!face.identity_path().exists());
|
||||
assert!(std::os::unix::net::UnixStream::connect(face.socket_path()).is_err());
|
||||
|
|
|
|||
Loading…
Reference in a new issue