From 446f6f4528278a65bdd8ee8d49e8d1e8e6ebcb4e Mon Sep 17 00:00:00 2001 From: Joerg Herbel Date: Tue, 14 Nov 2023 12:29:17 +0100 Subject: [PATCH 1/3] Move some code around This is a step towards fixing a bug in reporting that the scheduler is currently in the setup phase. --- v2/robotmk/src/bin/scheduler/main.rs | 6 ++++-- v2/robotmk/src/bin/scheduler/setup.rs | 3 +++ v2/robotmk/src/bin/scheduler/setup/mod.rs | 16 ---------------- 3 files changed, 7 insertions(+), 18 deletions(-) create mode 100644 v2/robotmk/src/bin/scheduler/setup.rs delete mode 100644 v2/robotmk/src/bin/scheduler/setup/mod.rs diff --git a/v2/robotmk/src/bin/scheduler/main.rs b/v2/robotmk/src/bin/scheduler/main.rs index f95d737d..fc86b061 100644 --- a/v2/robotmk/src/bin/scheduler/main.rs +++ b/v2/robotmk/src/bin/scheduler/main.rs @@ -47,8 +47,10 @@ fn run() -> Result<()> { } write_state(&results::SchedulerState::Setup, &global_config)?; - let suites = setup::setup(&global_config, suites)?; - debug!("Setup completed"); + setup::general::setup(&global_config, &suites).context("General setup failed")?; + debug!("General setup completed"); + let suites = setup::rcc::setup(&global_config, suites).context("RCC-specific setup failed")?; + debug!("RCC-specific setup completed"); if global_config.termination_flag.should_terminate() { bail!("Terminated") diff --git a/v2/robotmk/src/bin/scheduler/setup.rs b/v2/robotmk/src/bin/scheduler/setup.rs new file mode 100644 index 00000000..d321961f --- /dev/null +++ b/v2/robotmk/src/bin/scheduler/setup.rs @@ -0,0 +1,3 @@ +pub mod general; +mod icacls; +pub mod rcc; diff --git a/v2/robotmk/src/bin/scheduler/setup/mod.rs b/v2/robotmk/src/bin/scheduler/setup/mod.rs deleted file mode 100644 index 6200af35..00000000 --- a/v2/robotmk/src/bin/scheduler/setup/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -mod general; -mod icacls; -mod rcc; - -use crate::internal_config::{GlobalConfig, Suite}; - -use anyhow::{Context, Result}; -use log::debug; - -pub fn setup(global_config: &GlobalConfig, suites: Vec) -> Result> { - general::setup(global_config, &suites).context("General setup failed")?; - debug!("General setup completed"); - let suites = rcc::setup(global_config, suites).context("RCC-specific setup failed")?; - debug!("RCC-specific setup completed"); - Ok(suites) -} From 3f92019489f13fd55cfec4e71df5b9aeeb2978a4 Mon Sep 17 00:00:00 2001 From: Joerg Herbel Date: Tue, 14 Nov 2023 12:31:31 +0100 Subject: [PATCH 2/3] Do general setup before reporting any results We cannot report results before the general setup is completed because the necessary folders might be missing. --- v2/robotmk/src/bin/scheduler/main.rs | 2 +- v2/robotmk/src/bin/scheduler/results.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/robotmk/src/bin/scheduler/main.rs b/v2/robotmk/src/bin/scheduler/main.rs index fc86b061..cadf23a8 100644 --- a/v2/robotmk/src/bin/scheduler/main.rs +++ b/v2/robotmk/src/bin/scheduler/main.rs @@ -46,9 +46,9 @@ fn run() -> Result<()> { bail!("Terminated") } - write_state(&results::SchedulerState::Setup, &global_config)?; setup::general::setup(&global_config, &suites).context("General setup failed")?; debug!("General setup completed"); + write_state(&results::SchedulerState::RCCSetup, &global_config)?; let suites = setup::rcc::setup(&global_config, suites).context("RCC-specific setup failed")?; debug!("RCC-specific setup completed"); diff --git a/v2/robotmk/src/bin/scheduler/results.rs b/v2/robotmk/src/bin/scheduler/results.rs index 16c5ec92..60ffd2a9 100644 --- a/v2/robotmk/src/bin/scheduler/results.rs +++ b/v2/robotmk/src/bin/scheduler/results.rs @@ -14,7 +14,7 @@ pub fn suite_results_directory(results_directory: &Utf8Path) -> Utf8PathBuf { #[derive(Serialize)] pub enum SchedulerState { - Setup, + RCCSetup, EnvironmentBuilding, Scheduling, } From 00bfa3e6b995cf94b94a8c6ca5b4ffed71bdf902 Mon Sep 17 00:00:00 2001 From: Joerg Herbel Date: Tue, 14 Nov 2023 12:36:59 +0100 Subject: [PATCH 3/3] Rename `SchedulerState` --> `SchedulerPhase` The latter is more fitting. --- v2/robotmk/src/bin/scheduler/main.rs | 16 ++++++++-------- v2/robotmk/src/bin/scheduler/results.rs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/v2/robotmk/src/bin/scheduler/main.rs b/v2/robotmk/src/bin/scheduler/main.rs index cadf23a8..fc37d747 100644 --- a/v2/robotmk/src/bin/scheduler/main.rs +++ b/v2/robotmk/src/bin/scheduler/main.rs @@ -48,7 +48,7 @@ fn run() -> Result<()> { setup::general::setup(&global_config, &suites).context("General setup failed")?; debug!("General setup completed"); - write_state(&results::SchedulerState::RCCSetup, &global_config)?; + write_phase(&results::SchedulerPhase::RCCSetup, &global_config)?; let suites = setup::rcc::setup(&global_config, suites).context("RCC-specific setup failed")?; debug!("RCC-specific setup completed"); @@ -57,8 +57,8 @@ fn run() -> Result<()> { } info!("Starting environment building"); - write_state( - &results::SchedulerState::EnvironmentBuilding, + write_phase( + &results::SchedulerPhase::EnvironmentBuilding, &global_config, )?; let suites = environment::build_environments(&global_config, suites)?; @@ -69,16 +69,16 @@ fn run() -> Result<()> { } info!("Starting suite scheduling"); - write_state(&results::SchedulerState::Scheduling, &global_config)?; + write_phase(&results::SchedulerPhase::Scheduling, &global_config)?; scheduling::scheduler::run_suites_and_cleanup(&global_config, &suites) } -fn write_state( - state: &results::SchedulerState, +fn write_phase( + phase: &results::SchedulerPhase, global_config: &internal_config::GlobalConfig, ) -> Result<()> { - state.write( - global_config.results_directory.join("scheduler_state.json"), + phase.write( + global_config.results_directory.join("scheduler_phase.json"), &global_config.results_directory_locker, ) } diff --git a/v2/robotmk/src/bin/scheduler/results.rs b/v2/robotmk/src/bin/scheduler/results.rs index 60ffd2a9..e2104228 100644 --- a/v2/robotmk/src/bin/scheduler/results.rs +++ b/v2/robotmk/src/bin/scheduler/results.rs @@ -13,15 +13,15 @@ pub fn suite_results_directory(results_directory: &Utf8Path) -> Utf8PathBuf { } #[derive(Serialize)] -pub enum SchedulerState { +pub enum SchedulerPhase { RCCSetup, EnvironmentBuilding, Scheduling, } -impl WriteSection for SchedulerState { +impl WriteSection for SchedulerPhase { fn name() -> &'static str { - "robotmk_scheduler_state" + "robotmk_scheduler_phase" } }