Skip to content

Commit

Permalink
disabling III: simplify
Browse files Browse the repository at this point in the history
No change in behaviour. We need to change behaviour on exit code 5.
This change prepares it.

CMK-17546
  • Loading branch information
SoloJacobs committed Jun 25, 2024
1 parent 64bd07d commit ce0c3ba
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/bin/scheduler/setup/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use log::{debug, error};
use robotmk::results::{plan_results_directory, GeneralSetupFailures};
use robotmk::section::WriteSection;
use std::collections::{HashMap, HashSet};
use std::fs::{create_dir_all, remove_file};
use std::fs::{create_dir_all, remove_dir_all, remove_file};

pub fn setup(global_config: &GlobalConfig, plans: Vec<Plan>) -> AnyhowResult<Vec<Plan>> {
setup_working_directories(&global_config.working_directory, &plans)?;
Expand Down
66 changes: 47 additions & 19 deletions src/bin/scheduler/setup/rcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,33 +271,61 @@ fn holotree_init(
let mut failed_plans: HashMap<String, String> = HashMap::new();

for (session, plans) in plans_by_sessions(plans) {
let session_id = format!(
"{}_{}",
"holotree_initialization",
debug!("Running {} for `{}`", command_spec, &session);
let session_id = &format!(
"holotree_initialization_{}",
match &session {
Session::Current(_) => "current_user".into(),
Session::User(user_session) => format!("user_{}", user_session.user_name),
}
);

debug!("Running {} for `{}`", command_spec, &session);
match execute_run_spec_in_session(
&session,
&RunSpec {
id: &format!("robotmk_{session_id}"),
command_spec: &command_spec,
base_path: &rcc_setup_working_directory(&global_config.working_directory)
.join(session_id),
timeout: 120,
cancellation_token: &global_config.cancellation_token,
},
)? {
Some(error_msg) => {
let run_spec = &RunSpec {
id: &format!("robotmk_{session_id}"),
command_spec: &command_spec,
base_path: &rcc_setup_working_directory(&global_config.working_directory)
.join(session_id),
timeout: 120,
cancellation_token: &global_config.cancellation_token,
};
match session.run(run_spec) {
Ok(Outcome::Completed(0)) => {
debug!("{} for `{session}` successful", run_spec.command_spec);
succesful_plans.extend(plans);
}
Ok(Outcome::Completed(_)) => {
error!(
"{} for `{session}` exited non-successfully",
run_spec.command_spec
);
let error_message = format!(
"Non-zero exit code, see {} for stdio logs",
run_spec.base_path
);
for plan in plans {
failed_plans.insert(plan.id, error_msg.clone());
failed_plans.insert(plan.id, error_message.clone());
}
}
Ok(Outcome::Timeout) => {
error!("{} for `{session}` timed out", run_spec.command_spec);
for plan in plans {
failed_plans.insert(plan.id, "Timeout".to_string());
}
}
Ok(Outcome::Cancel) => {
error!("{} for `{session}` cancelled", run_spec.command_spec);
return Err(Cancelled {});
}
Err(error) => {
let error = error.context(format!(
"Failed to run {} for `{session}`",
run_spec.command_spec
));
let error = log_and_return_error(error);
let error_message = format!("{error:?}");
for plan in plans {
failed_plans.insert(plan.id, error_message.clone());
}
}
None => succesful_plans.extend(plans),
}
}

Expand Down

0 comments on commit ce0c3ba

Please sign in to comment.