Skip to content

Commit

Permalink
Make handling of cancellation more consistent in main::run.
Browse files Browse the repository at this point in the history
Return `Terminate::Cancelled` and the actual main function do the rest.
  • Loading branch information
jherbel committed Nov 27, 2024
1 parent 0a126d4 commit 8aab0a1
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/bin/scheduler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ fn run() -> Result<(), Terminate> {
);

if global_config.cancellation_token.is_cancelled() {
info!("Terminated");
return Ok(());
return Err(Terminate::Cancelled);
}

if let Some(grace_period) = args.grace_period {
Expand All @@ -70,8 +69,7 @@ fn run() -> Result<(), Terminate> {
info!("Setup steps completed");

if global_config.cancellation_token.is_cancelled() {
info!("Terminated");
return Ok(());
return Err(Terminate::Cancelled);
}

info!("Starting environment building");
Expand All @@ -80,15 +78,14 @@ fn run() -> Result<(), Terminate> {
info!("Environment building finished");

if global_config.cancellation_token.is_cancelled() {
info!("Terminated");
return Ok(());
return Err(Terminate::Cancelled);
}

info!("Starting plan scheduling");
write_phase(&SchedulerPhase::Scheduling, &global_config)?;
scheduling::scheduler::run_plans_and_cleanup(&global_config, &plans);
info!("Terminated");
Ok(())

Err(Terminate::Cancelled)
}

fn write_phase(
Expand Down

0 comments on commit 8aab0a1

Please sign in to comment.