diff --git a/v2/robotmk/src/bin/scheduler/internal_config.rs b/v2/robotmk/src/bin/scheduler/internal_config.rs index 79c0dba4..52c9d531 100644 --- a/v2/robotmk/src/bin/scheduler/internal_config.rs +++ b/v2/robotmk/src/bin/scheduler/internal_config.rs @@ -9,8 +9,6 @@ use robotmk::{ }; use camino::Utf8PathBuf; -use std::sync::Arc; -use std::sync::Mutex; use tokio_util::sync::CancellationToken; pub struct GlobalConfig { @@ -33,7 +31,6 @@ pub struct Suite { pub session: Session, pub working_directory_cleanup_config: WorkingDirectoryCleanupConfig, pub cancellation_token: CancellationToken, - pub parallelism_protection: Arc>, pub host: Host, pub results_directory_locker: Locker, } @@ -70,7 +67,6 @@ pub fn from_external_config( session: Session::new(&suite_config.session_config), working_directory_cleanup_config: suite_config.working_directory_cleanup_config, cancellation_token: cancellation_token.clone(), - parallelism_protection: Arc::new(Mutex::new(0)), host: suite_config.host, results_directory_locker: results_directory_locker.clone(), }) diff --git a/v2/robotmk/src/bin/scheduler/results.rs b/v2/robotmk/src/bin/scheduler/results.rs index 0ff40b8d..0eb7fdd0 100644 --- a/v2/robotmk/src/bin/scheduler/results.rs +++ b/v2/robotmk/src/bin/scheduler/results.rs @@ -99,7 +99,7 @@ pub enum EnvironmentBuildStatusError { #[derive(Serialize)] pub struct SuiteExecutionReport { pub suite_id: String, - pub outcome: ExecutionReport, + pub outcome: AttemptsOutcome, } impl WritePiggybackSection for SuiteExecutionReport { @@ -108,12 +108,6 @@ impl WritePiggybackSection for SuiteExecutionReport { } } -#[derive(Serialize)] -pub enum ExecutionReport { - Executed(AttemptsOutcome), - AlreadyRunning, -} - #[derive(Serialize)] pub struct AttemptsOutcome { pub attempts: Vec, diff --git a/v2/robotmk/src/bin/scheduler/scheduling/suites.rs b/v2/robotmk/src/bin/scheduler/scheduling/suites.rs index 5b50b658..a66758f1 100644 --- a/v2/robotmk/src/bin/scheduler/scheduling/suites.rs +++ b/v2/robotmk/src/bin/scheduler/scheduling/suites.rs @@ -1,8 +1,6 @@ use crate::environment::ResultCode; use crate::internal_config::Suite; -use crate::results::{ - AttemptOutcome, AttemptsConfig, AttemptsOutcome, ExecutionReport, SuiteExecutionReport, -}; +use crate::results::{AttemptOutcome, AttemptsConfig, AttemptsOutcome, SuiteExecutionReport}; use crate::rf::{rebot::Rebot, robot::Attempt}; use crate::sessions::session::{RunOutcome, RunSpec}; @@ -12,30 +10,12 @@ use chrono::Utc; use log::{debug, error}; use robotmk::section::WritePiggybackSection; use std::fs::create_dir_all; -use std::sync::{MutexGuard, TryLockError}; pub fn run_suite(suite: &Suite) -> Result<()> { - // We hold the lock as long as `_non_parallel_guard` is in scope - let _non_parallel_guard = try_acquire_suite_lock(suite).map_err(|err| { - let report = SuiteExecutionReport { - suite_id: suite.id.clone(), - outcome: ExecutionReport::AlreadyRunning, - }; - report - .write( - &suite.results_file, - suite.host.clone(), - &suite.results_directory_locker, - ) - .context("Reporting failure to acquire suite lock failed") - .err() - .unwrap_or(err) - })?; - debug!("Running suite {}", &suite.id); let report = SuiteExecutionReport { suite_id: suite.id.clone(), - outcome: ExecutionReport::Executed(produce_suite_results(suite)?), + outcome: produce_suite_results(suite)?, }; report .write( @@ -49,24 +29,6 @@ pub fn run_suite(suite: &Suite) -> Result<()> { Ok(()) } -fn try_acquire_suite_lock(suite: &Suite) -> Result> { - match suite.parallelism_protection.try_lock() { - Ok(non_parallel_guard) => Ok(non_parallel_guard), - Err(try_lock_error) => match try_lock_error { - TryLockError::WouldBlock => { - bail!( - "Failed to acquire lock for suite {}, skipping this run", - suite.id - ); - } - TryLockError::Poisoned(poison_error) => { - error!("Lock for suite {} poisoned, unpoisoning", suite.id); - Ok(poison_error.into_inner()) - } - }, - } -} - fn produce_suite_results(suite: &Suite) -> Result { let output_directory = suite .working_directory