Replace lexical Rust fragments with real modules
This commit is contained in:
parent
f8849cdb5f
commit
247819250b
1 changed files with 3302 additions and 2671 deletions
|
|
@ -1,4 +1,16 @@
|
|||
fn runsc_target(arguments: &RuntimeArguments, pid_file: i32) -> io::Result<TargetCommand> {
|
||||
use super::{
|
||||
AsFd, ChildStandardIo, CoordinatorMessage, Duration, File, FileExt, Instant,
|
||||
MAX_CONTROL_MESSAGE, NamespaceIdentity, ParentEdge, PollFd, PollFlags, PreparedNetwork,
|
||||
READINESS_TIMEOUT, RetainedProcess, RuntimeArguments, RuntimeGitRouting,
|
||||
RuntimeStateAnchorAbsenceAuthority, RuntimeStateAnchorMount, Serialize, Signal,
|
||||
SupervisorEvent, TERMINATION_GRACE, TargetCommand, Timespec, child_broker, decode, encode,
|
||||
inherited_directory_at, io, mount_identity, poll, read, write,
|
||||
};
|
||||
|
||||
pub(super) fn runsc_target(
|
||||
arguments: &RuntimeArguments,
|
||||
pid_file: i32,
|
||||
) -> io::Result<TargetCommand> {
|
||||
let run = arguments
|
||||
.runsc_arguments
|
||||
.iter()
|
||||
|
|
@ -15,7 +27,7 @@ fn runsc_target(arguments: &RuntimeArguments, pid_file: i32) -> io::Result<Targe
|
|||
Ok(target.with_parent_death_kill_edge())
|
||||
}
|
||||
|
||||
fn runsc_delete_target(arguments: &RuntimeArguments) -> io::Result<TargetCommand> {
|
||||
pub(super) fn runsc_delete_target(arguments: &RuntimeArguments) -> io::Result<TargetCommand> {
|
||||
let run = arguments
|
||||
.runsc_arguments
|
||||
.iter()
|
||||
|
|
@ -38,7 +50,7 @@ fn runsc_delete_target(arguments: &RuntimeArguments) -> io::Result<TargetCommand
|
|||
.argument(container))
|
||||
}
|
||||
|
||||
fn attached_runsc_standard_io(target: &TargetCommand) -> io::Result<ChildStandardIo> {
|
||||
pub(super) fn attached_runsc_standard_io(target: &TargetCommand) -> io::Result<ChildStandardIo> {
|
||||
if target.parent_edge() != ParentEdge::ParentDeathKill {
|
||||
return Err(io::Error::other(
|
||||
"attached runsc requires the parent-death KILL edge",
|
||||
|
|
@ -47,7 +59,7 @@ fn attached_runsc_standard_io(target: &TargetCommand) -> io::Result<ChildStandar
|
|||
Ok(ChildStandardIo::silenced())
|
||||
}
|
||||
|
||||
fn wait_for_runsc_ready(pid_file: &File, process: &RetainedProcess) -> io::Result<u32> {
|
||||
pub(super) fn wait_for_runsc_ready(pid_file: &File, process: &RetainedProcess) -> io::Result<u32> {
|
||||
let deadline = Instant::now() + READINESS_TIMEOUT;
|
||||
let mut bytes = [0_u8; 32];
|
||||
loop {
|
||||
|
|
@ -72,7 +84,7 @@ fn wait_for_runsc_ready(pid_file: &File, process: &RetainedProcess) -> io::Resul
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments, clippy::too_many_lines)]
|
||||
fn supervise(
|
||||
pub(super) fn supervise(
|
||||
control: &std::io::Stdout,
|
||||
process: RetainedProcess,
|
||||
mut git_routing: Option<RuntimeGitRouting>,
|
||||
|
|
@ -376,7 +388,7 @@ fn terminate_and_reap(process: RetainedProcess) -> io::Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
fn fail_with_runtime_cleanup(
|
||||
pub(super) fn fail_with_runtime_cleanup(
|
||||
process: RetainedProcess,
|
||||
git_routing: Option<RuntimeGitRouting>,
|
||||
network: Option<PreparedNetwork>,
|
||||
|
|
@ -427,7 +439,7 @@ fn cleanup_stopped_runtime(
|
|||
}
|
||||
}
|
||||
|
||||
fn fail_runtime_components<T>(
|
||||
pub(super) fn fail_runtime_components<T>(
|
||||
git_routing: Option<RuntimeGitRouting>,
|
||||
network: Option<PreparedNetwork>,
|
||||
error: io::Error,
|
||||
|
|
@ -494,7 +506,7 @@ fn stop_git_routing(routing: Option<RuntimeGitRouting>) -> io::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn wait_and_reap(process: RetainedProcess) -> io::Result<()> {
|
||||
pub(super) fn wait_and_reap(process: RetainedProcess) -> io::Result<()> {
|
||||
let deadline = Instant::now() + TERMINATION_GRACE;
|
||||
while !process.has_exited()? && Instant::now() < deadline {
|
||||
std::thread::sleep(Duration::from_millis(5));
|
||||
|
|
@ -509,7 +521,7 @@ fn wait_and_reap(process: RetainedProcess) -> io::Result<()> {
|
|||
child_broker().reap(process)
|
||||
}
|
||||
|
||||
fn fail_network<T>(network: Option<PreparedNetwork>, error: io::Error) -> io::Result<T> {
|
||||
pub(super) fn fail_network<T>(network: Option<PreparedNetwork>, error: io::Error) -> io::Result<T> {
|
||||
match stop_network(network) {
|
||||
Ok(()) => Err(error),
|
||||
Err(cleanup) => Err(io::Error::new(
|
||||
|
|
@ -526,7 +538,7 @@ fn stop_network(network: Option<PreparedNetwork>) -> io::Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
fn require_lifetime_held() -> io::Result<()> {
|
||||
pub(super) fn require_lifetime_held() -> io::Result<()> {
|
||||
if lifetime_lost()? {
|
||||
Err(io::Error::other("Host Coordinator lifetime lease is lost"))
|
||||
} else {
|
||||
|
|
@ -543,7 +555,7 @@ fn lifetime_lost() -> io::Result<bool> {
|
|||
.intersects(PollFlags::IN | PollFlags::HUP | PollFlags::ERR))
|
||||
}
|
||||
|
||||
fn send_message<T: lazaret_core::records::SchemaType + Serialize>(
|
||||
pub(super) fn send_message<T: lazaret_core::records::SchemaType + Serialize>(
|
||||
descriptor: impl AsFd,
|
||||
message: &T,
|
||||
) -> io::Result<()> {
|
||||
|
|
@ -558,7 +570,7 @@ fn send_message<T: lazaret_core::records::SchemaType + Serialize>(
|
|||
send_all(descriptor.as_fd(), &encoded)
|
||||
}
|
||||
|
||||
fn receive_message<T>(descriptor: impl AsFd) -> io::Result<T>
|
||||
pub(super) fn receive_message<T>(descriptor: impl AsFd) -> io::Result<T>
|
||||
where
|
||||
T: lazaret_core::records::SchemaType + serde::de::DeserializeOwned + Serialize,
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue