diff --git a/crates/sqlbuild-cli/Cargo.toml b/crates/sqlbuild-cli/Cargo.toml index e5955e6164..936e342a21 100644 --- a/crates/sqlbuild-cli/Cargo.toml +++ b/crates/sqlbuild-cli/Cargo.toml @@ -31,6 +31,7 @@ sqlbuild-core.workspace = true sqlbuild-cursor.workspace = true sqlbuild-model-config.workspace = true sqlbuild-orchestration.workspace = true +sqlbuild-process-ownership.workspace = true sqlbuild-recall.workspace = true sqlbuild-rules.workspace = true tokio.workspace = true @@ -39,9 +40,6 @@ uuid.workspace = true [target.'cfg(unix)'.dependencies] rustix.workspace = true -[target.'cfg(any(target_os = "linux", target_os = "macos", windows))'.dependencies] -sqlbuild-process-ownership.workspace = true - [target.'cfg(windows)'.dependencies] ctrlc.workspace = true same-file.workspace = true diff --git a/crates/sqlbuild-cli/src/workers/_helpers/child.rs b/crates/sqlbuild-cli/src/workers/_helpers/child.rs index 52fcb10161..fb14d6452e 100644 --- a/crates/sqlbuild-cli/src/workers/_helpers/child.rs +++ b/crates/sqlbuild-cli/src/workers/_helpers/child.rs @@ -2,7 +2,6 @@ use sqlbuild_orchestration::store::errors::ControlError; -#[cfg(any(target_os = "linux", target_os = "macos", windows))] use sqlbuild_process_ownership::ownership::main::{ stop_worker::stop_worker, worker_exited::worker_exited, }; @@ -28,7 +27,6 @@ impl WorkerChild { Self::Local(child) => Ok(child .try_wait()? .map(|exit| WorkerExit::Code(exit_code(exit)))), - #[cfg(any(target_os = "linux", target_os = "macos", windows))] Self::RecoveredLocal(owner) => Ok(worker_exited(owner)?.then_some(WorkerExit::Absent)), Self::Docker(child) => child.try_wait().await, } @@ -49,7 +47,6 @@ impl WorkerChild { pub(in crate::workers) async fn terminate(&mut self) -> Result<(), ControlError> { match self { Self::Local(child) => terminate_child(child), - #[cfg(any(target_os = "linux", target_os = "macos", windows))] Self::RecoveredLocal(owner) => Ok(stop_worker(owner, false)?), Self::Docker(child) => child.signal("SIGTERM").await, } @@ -61,7 +58,6 @@ impl WorkerChild { child.start_kill()?; Ok(()) } - #[cfg(any(target_os = "linux", target_os = "macos", windows))] Self::RecoveredLocal(owner) => Ok(stop_worker(owner, true)?), Self::Docker(child) => child.signal("SIGKILL").await, } diff --git a/crates/sqlbuild-cli/src/workers/_helpers/recovery.rs b/crates/sqlbuild-cli/src/workers/_helpers/recovery.rs index fb08f51c14..6d2e706260 100644 --- a/crates/sqlbuild-cli/src/workers/_helpers/recovery.rs +++ b/crates/sqlbuild-cli/src/workers/_helpers/recovery.rs @@ -9,7 +9,6 @@ use sqlbuild_orchestration::scheduler::models::SchedulerLease; use sqlbuild_orchestration::store::errors::ControlError; use sqlbuild_orchestration::store::models::ControlStore; -#[cfg(any(target_os = "linux", target_os = "macos", windows))] use sqlbuild_process_ownership::ownership::main::recover_worker::recover_worker; use crate::workers::models::{ClaimedWorker, DockerWorker, Launcher, WorkerChild, Workers}; @@ -29,10 +28,6 @@ impl Workers { .map(|worker| worker.claim.claim_id) .collect(); for location in self.configuration.locations() { - #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))] - if matches!(location, Launcher::Local(_)) { - continue; - } let scope = location.scope(); let mut after = None; loop { @@ -48,12 +43,9 @@ impl Workers { continue; } let child = match location { - #[cfg(any(target_os = "linux", target_os = "macos", windows))] Launcher::Local(location) => Some(WorkerChild::RecoveredLocal( recover_worker(&location.claim(&claim))?, )), - #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))] - Launcher::Local(_) => continue, Launcher::Docker(location) => match DockerWorker::prepare(location, &claim) { Ok(child) => Some(WorkerChild::Docker(child)), diff --git a/crates/sqlbuild-cli/src/workers/_helpers/supervisor.rs b/crates/sqlbuild-cli/src/workers/_helpers/supervisor.rs index 9411afe732..a08f9e04fd 100644 --- a/crates/sqlbuild-cli/src/workers/_helpers/supervisor.rs +++ b/crates/sqlbuild-cli/src/workers/_helpers/supervisor.rs @@ -19,7 +19,6 @@ use sqlbuild_orchestration::scheduler::main::renew_lease::renew_lease; use sqlbuild_orchestration::scheduler::models::SchedulerLease; use sqlbuild_orchestration::store::errors::ControlError; use sqlbuild_orchestration::store::models::ControlStore; -#[cfg(any(target_os = "linux", target_os = "macos", windows))] use sqlbuild_process_ownership::ownership::main::{ prepare_worker::prepare_worker, start_worker::start_worker, }; @@ -328,19 +327,13 @@ fn prepare_spawn( .stdin(Stdio::null()) .stdout(Stdio::null()) .stderr(Stdio::inherit()); - #[cfg(any(target_os = "linux", target_os = "macos", windows))] let (command, ownership) = prepare_worker(command, &location.claim(claim))?; let mut command = Command::from(command); command.kill_on_drop(true); - Ok(LocalSpawn { - command, - #[cfg(any(target_os = "linux", target_os = "macos", windows))] - ownership, - }) + Ok(LocalSpawn { command, ownership }) } impl LocalLauncher { - #[cfg(any(target_os = "linux", target_os = "macos", windows))] pub(in crate::workers) fn claim<'a>( &'a self, claim: &RunClaim, @@ -357,7 +350,6 @@ impl LocalSpawn { /// A child whose ownership could not be completed is killed before the error is returned. fn spawn(mut self) -> Result { let mut child = self.command.spawn()?; - #[cfg(any(target_os = "linux", target_os = "macos", windows))] if let Err(error) = child .id() .ok_or_else(|| std::io::Error::other("worker exited before it was owned")) diff --git a/crates/sqlbuild-cli/src/workers/models.rs b/crates/sqlbuild-cli/src/workers/models.rs index e6eb0e5abb..e64217bd12 100644 --- a/crates/sqlbuild-cli/src/workers/models.rs +++ b/crates/sqlbuild-cli/src/workers/models.rs @@ -13,7 +13,6 @@ use uuid::Uuid; #[derive(Debug)] pub(super) enum WorkerChild { Local(Child), - #[cfg(any(target_os = "linux", target_os = "macos", windows))] RecoveredLocal(sqlbuild_process_ownership::ownership::models::RecoveredOwnership), Docker(DockerWorker), } @@ -22,7 +21,6 @@ pub(super) enum WorkerChild { #[derive(Debug)] pub(super) struct LocalSpawn { pub(super) command: tokio::process::Command, - #[cfg(any(target_os = "linux", target_os = "macos", windows))] pub(super) ownership: sqlbuild_process_ownership::ownership::models::PendingOwnership, } diff --git a/crates/sqlbuild-orchestration/tests/runs/test_monitor.rs b/crates/sqlbuild-orchestration/tests/runs/test_monitor.rs index 62fe549bc8..a10b3a2a4c 100644 --- a/crates/sqlbuild-orchestration/tests/runs/test_monitor.rs +++ b/crates/sqlbuild-orchestration/tests/runs/test_monitor.rs @@ -77,7 +77,6 @@ fn given_silent_and_live_workers_when_the_scheduler_monitors_then_fenced_atomic_ .expect("leader"); let silent = start_run(store, &lease, &request(scope, 1, 0, &["orders"])).await; start_run(store, &lease, &request(scope, 2, 0, &["customers"])).await; - age_heartbeat(store, Uuid::from_u128(2), 40).await; queue(store, &request(scope, 3, 0, &["inventory"])).await; let launching = claim_next_run(store, &lease, &BTreeMap::new(), None) .await @@ -153,6 +152,7 @@ fn given_silent_and_live_workers_when_the_scheduler_monitors_then_fenced_atomic_ .expect("projection rollback"), projection ); + age_heartbeat(store, Uuid::from_u128(2), 5).await; expire_lease(store).await; let (state, observed) = scheduler_cycle(store, SchedulerState::new(holder)) .await