Skip to content

Commit

Permalink
Setup steps: Factor out session-speficif RCC working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jherbel committed Nov 25, 2024
1 parent 81a207a commit ff90440
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/bin/scheduler/setup/steps/directories.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::api::{self, skip, SetupStep, StepWithPlans};
use super::{partition_into_rcc_and_system_plans, plans_by_sessions};
use super::{
partition_into_rcc_and_system_plans, plans_by_sessions, rcc_working_directory_for_session,
};

use crate::internal_config::{GlobalConfig, Plan, Source};
#[cfg(windows)]
Expand Down Expand Up @@ -176,7 +178,10 @@ pub fn gather_rcc_working_per_user(config: &GlobalConfig, plans: Vec<Plan>) -> V
for (session, plans_in_session) in plans_by_sessions(rcc_plans) {
setup_steps.push((
Box::new(StepCreateWithAccess {
target: config.working_directory_rcc_setup_steps.join(session.id()),
target: rcc_working_directory_for_session(
&config.working_directory_rcc_setup_steps,
&session,
),
session,
}),
plans_in_session,
Expand All @@ -196,9 +201,10 @@ pub fn gather_rcc_longpath_directory(
vec![
(
Box::new(StepCreate {
target: config
.working_directory_rcc_setup_steps
.join(CurrentSession {}.id()),
target: rcc_working_directory_for_session(
&config.working_directory_rcc_setup_steps,
&Session::Current(CurrentSession {}),
),
}),
rcc_plans,
),
Expand Down
8 changes: 8 additions & 0 deletions src/bin/scheduler/setup/steps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod run;

use crate::internal_config::Plan;

use camino::{Utf8Path, Utf8PathBuf};
use robotmk::environment::Environment;
use robotmk::session::Session;
use std::collections::HashMap;
Expand All @@ -25,3 +26,10 @@ fn partition_into_rcc_and_system_plans(plans: Vec<Plan>) -> (Vec<Plan>, Vec<Plan
.into_iter()
.partition(|plan| matches!(plan.environment, Environment::Rcc(_)))
}

fn rcc_working_directory_for_session(
working_directory_rcc_setup_steps: &Utf8Path,
session: &Session,
) -> Utf8PathBuf {
working_directory_rcc_setup_steps.join(session.id())
}
19 changes: 13 additions & 6 deletions src/bin/scheduler/setup/steps/rcc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::api::{self, skip, SetupStep, StepWithPlans};
use super::{partition_into_rcc_and_system_plans, plans_by_sessions};
use super::{
partition_into_rcc_and_system_plans, plans_by_sessions, rcc_working_directory_for_session,
};

use crate::internal_config::{GlobalConfig, Plan};
use crate::logging::log_and_return_error;
Expand Down Expand Up @@ -99,10 +101,11 @@ impl SetupStep for StepRCCCommand {
let run_spec = RunSpec {
id: &format!("robotmk_{}", self.id),
command_spec: &command_spec,
runtime_base_path: &self
.working_directory
.join(self.session.id())
.join(&self.id),
runtime_base_path: &rcc_working_directory_for_session(
&self.working_directory,
&self.session,
)
.join(&self.id),
timeout: 120,
cancellation_token: &self.cancellation_token,
};
Expand Down Expand Up @@ -190,7 +193,11 @@ impl SetupStep for StepDisableSharedHolotree {
let run_spec = &RunSpec {
id: &format!("robotmk_{name}_{}", self.session.id()),
command_spec: &command_spec,
runtime_base_path: &self.working_directory.join(self.session.id()).join(name),
runtime_base_path: &rcc_working_directory_for_session(
&self.working_directory,
&self.session,
)
.join(name),
timeout: 120,
cancellation_token: &self.cancellation_token,
};
Expand Down

0 comments on commit ff90440

Please sign in to comment.