Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions crates/sqlbuild-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions crates/sqlbuild-cli/src/workers/_helpers/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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,
}
Expand All @@ -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,
}
Expand All @@ -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,
}
Expand Down
8 changes: 0 additions & 8 deletions crates/sqlbuild-cli/src/workers/_helpers/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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 {
Expand All @@ -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)),
Expand Down
10 changes: 1 addition & 9 deletions crates/sqlbuild-cli/src/workers/_helpers/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand All @@ -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<tokio::process::Child, ControlError> {
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"))
Expand Down
2 changes: 0 additions & 2 deletions crates/sqlbuild-cli/src/workers/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand All @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/sqlbuild-orchestration/tests/runs/test_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading