Skip to content

Commit

Permalink
disabling IV: run with --revoke
Browse files Browse the repository at this point in the history
We revoke access to the shared holotree. This might fail because the
session did not have access to begin with. In this case, RCC returns
with exit code 5.

Plans, where revoking access failed, are skipped.

CMK-17546
  • Loading branch information
SoloJacobs committed Jun 25, 2024
1 parent ce0c3ba commit 5fcd688
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
26 changes: 16 additions & 10 deletions src/bin/scheduler/setup/rcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,16 @@ fn rcc_setup(
);
}

debug!("Initializing holotree");
(sucessful_plans, rcc_setup_failures.holotree_init) =
holotree_init(global_config, sucessful_plans)
.context("Received termination signal while initializing holotree")?;
if !rcc_setup_failures.holotree_init.is_empty() {
debug!("Disabling shared holotree");
(
sucessful_plans,
rcc_setup_failures.holotree_disabling_sharing,
) = holotree_disable_sharing(global_config, sucessful_plans)
.context("Received termination signal while revoking shared holotree")?;
if !rcc_setup_failures.holotree_disabling_sharing.is_empty() {
error!(
"Dropping the following plans due to holotree initialization failure: {}",
failed_plan_ids_human_readable(rcc_setup_failures.holotree_init.keys())
"Dropping the following plans due to failing to disable holotree sharing: {}",
failed_plan_ids_human_readable(rcc_setup_failures.holotree_disabling_sharing.keys())
);
}

Expand Down Expand Up @@ -260,20 +262,20 @@ fn enable_long_path_support(
)
}

fn holotree_init(
fn holotree_disable_sharing(
global_config: &GlobalConfig,
plans: Vec<Plan>,
) -> Result<(Vec<Plan>, HashMap<String, String>), Cancelled> {
let mut command_spec =
RCCEnvironment::bundled_command_spec(&global_config.rcc_config.binary_path);
command_spec.add_arguments(["holotree", "init"]);
command_spec.add_arguments(["holotree", "init", "--revoke"]);
let mut succesful_plans = vec![];
let mut failed_plans: HashMap<String, String> = HashMap::new();

for (session, plans) in plans_by_sessions(plans) {
debug!("Running {} for `{}`", command_spec, &session);
let session_id = &format!(
"holotree_initialization_{}",
"holotree_disabling_sharing_{}",
match &session {
Session::Current(_) => "current_user".into(),
Session::User(user_session) => format!("user_{}", user_session.user_name),
Expand All @@ -292,6 +294,10 @@ fn holotree_init(
debug!("{} for `{session}` successful", run_spec.command_spec);
succesful_plans.extend(plans);
}
Ok(Outcome::Completed(5)) => {
debug!("`{session}` not using shared holotree. Don't need to disable.");
succesful_plans.extend(plans);
}
Ok(Outcome::Completed(_)) => {
error!(
"{} for `{session}` exited non-successfully",
Expand Down
2 changes: 1 addition & 1 deletion src/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct RCCSetupFailures {
pub telemetry_disabling: HashMap<String, String>,
pub profile_configuring: HashMap<String, String>,
pub long_path_support: HashMap<String, String>,
pub holotree_init: HashMap<String, String>,
pub holotree_disabling_sharing: HashMap<String, String>,
}

impl WriteSection for RCCSetupFailures {
Expand Down
16 changes: 10 additions & 6 deletions tests/test_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ async fn assert_working_directory(
&format!("custom_profile_switch_user_{headed_user_name}.exit_code"),
&format!("custom_profile_switch_user_{headed_user_name}.stderr"),
&format!("custom_profile_switch_user_{headed_user_name}.stdout"),
"holotree_initialization_current_user.stderr",
"holotree_initialization_current_user.stdout",
&format!("holotree_initialization_user_{headed_user_name}.bat"),
&format!("holotree_initialization_user_{headed_user_name}.exit_code"),
&format!("holotree_initialization_user_{headed_user_name}.stderr"),
&format!("holotree_initialization_user_{headed_user_name}.stdout"),
"holotree_disabling_sharing_current_user.stderr",
"holotree_disabling_sharing_current_user.stdout",
&format!("holotree_disabling_sharing_user_{headed_user_name}.bat"),
&format!("holotree_disabling_sharing_user_{headed_user_name}.exit_code"),
&format!("holotree_disabling_sharing_user_{headed_user_name}.stderr"),
&format!("holotree_disabling_sharing_user_{headed_user_name}.stdout"),
"long_path_support_enabling.stderr",
"long_path_support_enabling.stdout",
"telemetry_disabling_current_user.stderr",
Expand Down Expand Up @@ -332,6 +332,10 @@ async fn assert_rcc_configuration(rcc_config: &RCCConfig) -> AnyhowResult<()> {
.as_str(),
"false"
);
assert_eq!(
diagnostics.details.get("holotree-shared").unwrap().as_str(),
"false"
);
if let RCCProfileConfig::Custom(custom_rcc_profile_config) = &rcc_config.profile_config {
assert_eq!(
diagnostics
Expand Down

0 comments on commit 5fcd688

Please sign in to comment.