From 5fcd688b4d6f4b44090312347f00317c2fdf09b0 Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Sat, 15 Jun 2024 13:45:46 +0200 Subject: [PATCH] disabling IV: run with --revoke 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 --- src/bin/scheduler/setup/rcc.rs | 26 ++++++++++++++++---------- src/results.rs | 2 +- tests/test_scheduler.rs | 16 ++++++++++------ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/bin/scheduler/setup/rcc.rs b/src/bin/scheduler/setup/rcc.rs index 6bbdc680..3d254485 100644 --- a/src/bin/scheduler/setup/rcc.rs +++ b/src/bin/scheduler/setup/rcc.rs @@ -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()) ); } @@ -260,20 +262,20 @@ fn enable_long_path_support( ) } -fn holotree_init( +fn holotree_disable_sharing( global_config: &GlobalConfig, plans: Vec, ) -> Result<(Vec, HashMap), 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 = 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), @@ -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", diff --git a/src/results.rs b/src/results.rs index 067053f7..90ed64a3 100644 --- a/src/results.rs +++ b/src/results.rs @@ -40,7 +40,7 @@ pub struct RCCSetupFailures { pub telemetry_disabling: HashMap, pub profile_configuring: HashMap, pub long_path_support: HashMap, - pub holotree_init: HashMap, + pub holotree_disabling_sharing: HashMap, } impl WriteSection for RCCSetupFailures { diff --git a/tests/test_scheduler.rs b/tests/test_scheduler.rs index a5367d9d..c0798dc8 100644 --- a/tests/test_scheduler.rs +++ b/tests/test_scheduler.rs @@ -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", @@ -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