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
|
|
@ -15,8 +15,8 @@ use lazaret_core::identity::{
|
|||
};
|
||||
use lazaret_core::records::{ArtifactState, PreparedArtifact};
|
||||
use lazaret_state_anchor::{
|
||||
ProtectedRuntimeFiles, RuntimeStateAnchorAuthority, StateAnchorLaunchAuthority,
|
||||
StateAnchorLayout,
|
||||
ProtectedRuntimeFiles, RuntimeStateAnchorAuthority, RuntimeStateAnchorInherited,
|
||||
StateAnchorLaunchAuthority, StateAnchorLayout,
|
||||
};
|
||||
|
||||
static SEQUENCE: AtomicU64 = AtomicU64::new(0);
|
||||
|
|
@ -78,30 +78,12 @@ fn inherited_runtime_authority_accepts_only_the_exact_prepared_lower() {
|
|||
};
|
||||
let launch = StateAnchorLaunchAuthority::capture(&layout, &artifact).unwrap();
|
||||
let expected = launch.expected_lower();
|
||||
RuntimeStateAnchorAuthority::from_inherited(
|
||||
launch.lower_fd(),
|
||||
launch.lower_label(),
|
||||
launch.persistent_root_fd(),
|
||||
launch.persistent_anchor_fd(),
|
||||
launch.persistent_anchor_label(),
|
||||
launch.runtime_root_fd(),
|
||||
launch.runtime_anchor_fd(),
|
||||
launch.runtime_anchor_label(),
|
||||
expected,
|
||||
)
|
||||
.unwrap();
|
||||
RuntimeStateAnchorAuthority::from_inherited(inherited(&launch, expected)).unwrap();
|
||||
assert!(
|
||||
RuntimeStateAnchorAuthority::from_inherited(
|
||||
launch.lower_fd(),
|
||||
launch.lower_label(),
|
||||
launch.persistent_root_fd(),
|
||||
launch.persistent_anchor_fd(),
|
||||
launch.persistent_anchor_label(),
|
||||
launch.runtime_root_fd(),
|
||||
launch.runtime_anchor_fd(),
|
||||
launch.runtime_anchor_label(),
|
||||
RuntimeStateAnchorAuthority::from_inherited(inherited(
|
||||
&launch,
|
||||
(expected.0, expected.1 + 1),
|
||||
)
|
||||
))
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
|
@ -150,18 +132,8 @@ fn namespace_local_rebound_refuses_a_replaced_state_anchor() {
|
|||
fs::create_dir(&anchor).unwrap();
|
||||
|
||||
assert!(
|
||||
RuntimeStateAnchorAuthority::from_inherited(
|
||||
launch.lower_fd(),
|
||||
launch.lower_label(),
|
||||
launch.persistent_root_fd(),
|
||||
launch.persistent_anchor_fd(),
|
||||
launch.persistent_anchor_label(),
|
||||
launch.runtime_root_fd(),
|
||||
launch.runtime_anchor_fd(),
|
||||
launch.runtime_anchor_label(),
|
||||
launch.expected_lower(),
|
||||
)
|
||||
.is_err()
|
||||
RuntimeStateAnchorAuthority::from_inherited(inherited(&launch, launch.expected_lower(),))
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -178,18 +150,8 @@ fn namespace_local_rebound_refuses_a_replaced_prepared_lower() {
|
|||
fs::create_dir(&lower).unwrap();
|
||||
|
||||
assert!(
|
||||
RuntimeStateAnchorAuthority::from_inherited(
|
||||
launch.lower_fd(),
|
||||
launch.lower_label(),
|
||||
launch.persistent_root_fd(),
|
||||
launch.persistent_anchor_fd(),
|
||||
launch.persistent_anchor_label(),
|
||||
launch.runtime_root_fd(),
|
||||
launch.runtime_anchor_fd(),
|
||||
launch.runtime_anchor_label(),
|
||||
launch.expected_lower(),
|
||||
)
|
||||
.is_err()
|
||||
RuntimeStateAnchorAuthority::from_inherited(inherited(&launch, launch.expected_lower(),))
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -207,18 +169,8 @@ fn namespace_local_rebound_refuses_a_replaced_persistent_anchor() {
|
|||
fs::create_dir(&anchor).unwrap();
|
||||
|
||||
assert!(
|
||||
RuntimeStateAnchorAuthority::from_inherited(
|
||||
launch.lower_fd(),
|
||||
launch.lower_label(),
|
||||
launch.persistent_root_fd(),
|
||||
launch.persistent_anchor_fd(),
|
||||
launch.persistent_anchor_label(),
|
||||
launch.runtime_root_fd(),
|
||||
launch.runtime_anchor_fd(),
|
||||
launch.runtime_anchor_label(),
|
||||
launch.expected_lower(),
|
||||
)
|
||||
.is_err()
|
||||
RuntimeStateAnchorAuthority::from_inherited(inherited(&launch, launch.expected_lower(),))
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -237,21 +189,28 @@ fn namespace_local_rebound_refuses_a_state_anchor_symlink() {
|
|||
std::os::unix::fs::symlink(&retained, &anchor).unwrap();
|
||||
|
||||
assert!(
|
||||
RuntimeStateAnchorAuthority::from_inherited(
|
||||
launch.lower_fd(),
|
||||
launch.lower_label(),
|
||||
launch.persistent_root_fd(),
|
||||
launch.persistent_anchor_fd(),
|
||||
launch.persistent_anchor_label(),
|
||||
launch.runtime_root_fd(),
|
||||
launch.runtime_anchor_fd(),
|
||||
launch.runtime_anchor_label(),
|
||||
launch.expected_lower(),
|
||||
)
|
||||
.is_err()
|
||||
RuntimeStateAnchorAuthority::from_inherited(inherited(&launch, launch.expected_lower(),))
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
fn inherited(
|
||||
launch: &StateAnchorLaunchAuthority,
|
||||
expected_lower: (u64, u64),
|
||||
) -> RuntimeStateAnchorInherited<'_> {
|
||||
RuntimeStateAnchorInherited {
|
||||
lower_fd: launch.lower_fd(),
|
||||
lower_label: launch.lower_label(),
|
||||
persistent_root_fd: launch.persistent_root_fd(),
|
||||
persistent_anchor_fd: launch.persistent_anchor_fd(),
|
||||
persistent_anchor_label: launch.persistent_anchor_label(),
|
||||
runtime_root_fd: launch.runtime_root_fd(),
|
||||
runtime_anchor_fd: launch.runtime_anchor_fd(),
|
||||
runtime_anchor_label: launch.runtime_anchor_label(),
|
||||
expected_lower,
|
||||
}
|
||||
}
|
||||
|
||||
fn prepared_artifact(lower: &Path) -> PreparedArtifact {
|
||||
let metadata = lower.metadata().unwrap();
|
||||
PreparedArtifact {
|
||||
|
|
|
|||
Loading…
Reference in a new issue