@@ -4,7 +4,6 @@ use std::{
44 io:: BufReader ,
55 path:: { Path , PathBuf } ,
66 process:: { ExitStatus , Stdio } ,
7- sync:: atomic:: { AtomicBool , Ordering } ,
87} ;
98
109use anyhow:: anyhow;
@@ -46,14 +45,6 @@ static PROJECT_ROOT: Lazy<String> =
4645const DEFAULT_PREHEAT_SHALLOW_DEPTH : usize = 3 ;
4746static BUILD_CONFIG : Lazy < Option < BuildConfig > > = Lazy :: new ( load_build_config) ;
4847
49- /// Check whether failed-build mounts should be kept alive for debugging.
50- /// Controlled by the `ORION_KEEP_FAILED_MOUNTS` environment variable (set to "1" to enable).
51- fn keep_failed_mounts ( ) -> bool {
52- std:: env:: var ( "ORION_KEEP_FAILED_MOUNTS" )
53- . map ( |v| v == "1" )
54- . unwrap_or ( false )
55- }
56-
5748/// Mount an Antares overlay filesystem for a build job.
5849///
5950/// Creates a new Antares overlay mount using scorpiofs. The underlying Dicfuse
@@ -512,63 +503,6 @@ async fn flush_buffer(
512503 }
513504}
514505
515- /// RAII guard for automatically unmounting Antares filesystem when dropped
516- struct MountGuard {
517- mount_id : String ,
518- task_id : String ,
519- unmounted : AtomicBool ,
520- }
521-
522- impl MountGuard {
523- fn new ( mount_id : String , task_id : String ) -> Self {
524- Self {
525- mount_id,
526- task_id,
527- unmounted : AtomicBool :: new ( false ) ,
528- }
529- }
530-
531- async fn unmount ( & self ) {
532- if self . unmounted . swap ( true , Ordering :: AcqRel ) {
533- return ;
534- }
535- match unmount_antares_fs ( & self . mount_id ) . await {
536- Ok ( _) => tracing:: info!( "[Task {}] Filesystem unmounted successfully." , self . task_id) ,
537- Err ( e) => {
538- tracing:: error!(
539- "[Task {}] Failed to unmount filesystem: {}" ,
540- self . task_id,
541- e
542- )
543- }
544- }
545- }
546- }
547-
548- impl Drop for MountGuard {
549- fn drop ( & mut self ) {
550- if self . unmounted . load ( Ordering :: Acquire ) {
551- return ;
552- }
553- if keep_failed_mounts ( ) {
554- tracing:: info!(
555- "[Task {}] MountGuard dropped — unmount skipped (ORION_KEEP_FAILED_MOUNTS=1, mount_id={})." ,
556- self . task_id,
557- self . mount_id,
558- ) ;
559- return ;
560- }
561- let mount_id = self . mount_id . clone ( ) ;
562- let task_id: String = self . task_id . clone ( ) ;
563- tokio:: spawn ( async move {
564- match unmount_antares_fs ( & mount_id) . await {
565- Ok ( _) => tracing:: info!( "[Task {}] Filesystem unmounted successfully." , task_id) ,
566- Err ( e) => tracing:: error!( "[Task {}] Failed to unmount filesystem: {}" , task_id, e) ,
567- }
568- } ) ;
569- }
570- }
571-
572506/// Executes buck build with filesystem mounting and output streaming.
573507///
574508/// Process flow:
@@ -612,8 +546,6 @@ pub async fn build(
612546 const MAX_TARGETS_ATTEMPTS : usize = 2 ;
613547 let mut mount_point = None ;
614548 let mut old_repo_mount_point_saved = None ;
615- let mut mount_guard = None ;
616- let mut mount_guard_old_repo = None ;
617549 let mut targets: Vec < TargetLabel > = Vec :: new ( ) ;
618550 let mut last_targets_error: Option < anyhow:: Error > = None ;
619551
@@ -629,13 +561,11 @@ pub async fn build(
629561 // Buck2 isolates daemons by project root, so distinct mount paths
630562 // naturally get separate daemons without needing `--isolation-dir`.
631563 let id_for_old_repo = format ! ( "{id}-old-{attempt}" ) ;
632- let ( old_repo_mount_point, mount_id_old_repo ) =
564+ let ( old_repo_mount_point, _mount_id_old_repo ) =
633565 mount_antares_fs ( & id_for_old_repo, None ) . await ?;
634- let guard_old_repo = MountGuard :: new ( mount_id_old_repo. clone ( ) , id_for_old_repo) ;
635566
636567 let id_for_repo = format ! ( "{id}-{attempt}" ) ;
637- let ( repo_mount_point, mount_id) = mount_antares_fs ( & id_for_repo, cl_arg) . await ?;
638- let guard = MountGuard :: new ( mount_id. clone ( ) , id_for_repo) ;
568+ let ( repo_mount_point, _mount_id) = mount_antares_fs ( & id_for_repo, cl_arg) . await ?;
639569
640570 tracing:: info!(
641571 "[Task {}] Filesystem mounted successfully (attempt {}/{})." ,
@@ -658,23 +588,12 @@ pub async fn build(
658588 Ok ( found_targets) => {
659589 mount_point = Some ( repo_mount_point) ;
660590 old_repo_mount_point_saved = Some ( old_repo_mount_point. clone ( ) ) ;
661- mount_guard = Some ( guard) ;
662- mount_guard_old_repo = Some ( guard_old_repo) ;
663591 targets = found_targets;
664592 break ;
665593 }
666594 Err ( e) => {
667- if keep_failed_mounts ( ) {
668- tracing:: info!(
669- "[Task {}] Keeping failed mounts alive for debugging (ORION_KEEP_FAILED_MOUNTS=1)" ,
670- id,
671- ) ;
672- } else {
673- guard. unmount ( ) . await ;
674- guard_old_repo. unmount ( ) . await ;
675- }
676595 tracing:: warn!(
677- "[Task {}] Failed to get build targets (attempt {}/{}): {}. Mounts kept alive for debugging (old={}, new={})." ,
596+ "[Task {}] Failed to get build targets (attempt {}/{}): {}. Mounts retained for debugging (old={}, new={})." ,
678597 id,
679598 attempt,
680599 MAX_TARGETS_ATTEMPTS ,
@@ -712,9 +631,6 @@ pub async fn build(
712631 return Err ( err. into ( ) ) ;
713632 }
714633 } ;
715- let mount_guard = mount_guard. ok_or ( "Mount guard missing after target discovery" ) ?;
716- let mount_guard_old_repo =
717- mount_guard_old_repo. ok_or ( "Old repo mount guard missing after target discovery" ) ?;
718634
719635 let build_result = async {
720636 // Run buck2 build from the sub-project directory, not the monorepo root.
@@ -830,41 +746,14 @@ pub async fn build(
830746 }
831747 . await ;
832748
833- if keep_failed_mounts ( ) {
834- tracing:: info!(
835- "[Task {}] Skipping unmount (ORION_KEEP_FAILED_MOUNTS=1) — mount directories retained: \
836- new_repo mountpoint={}, mount_id={}; \
837- old_repo mountpoint={}, mount_id={}",
838- id,
839- mount_point,
840- mount_guard. mount_id,
841- old_repo_mount_point_saved. as_deref( ) . unwrap_or( "<unknown>" ) ,
842- mount_guard_old_repo. mount_id,
843- ) ;
844- // Prevent the Drop impl from unmounting.
845- mount_guard. unmounted . store ( true , Ordering :: Release ) ;
846- mount_guard_old_repo
847- . unmounted
848- . store ( true , Ordering :: Release ) ;
849- } else {
850- mount_guard. unmount ( ) . await ;
851- mount_guard_old_repo. unmount ( ) . await ;
852- }
749+ tracing:: info!(
750+ "[Task {}] Build completed — mount directories retained for debugging: \
751+ new_repo mountpoint={}; \
752+ old_repo mountpoint={}",
753+ id,
754+ mount_point,
755+ old_repo_mount_point_saved. as_deref( ) . unwrap_or( "<unknown>" ) ,
756+ ) ;
853757
854758 build_result
855- }
856-
857- #[ cfg( test) ]
858- mod tests {
859- use super :: * ;
860-
861- #[ tokio:: test]
862- async fn test_mount_guard_creation ( ) {
863- let mount_guard = MountGuard :: new ( "test_mount_id" . to_string ( ) , "test_task_id" . to_string ( ) ) ;
864- assert_eq ! ( mount_guard. mount_id, "test_mount_id" ) ;
865- assert_eq ! ( mount_guard. task_id, "test_task_id" ) ;
866- }
867-
868- // Note: mount/unmount tests removed - they now use scorpiofs direct calls
869- // which require actual filesystem setup. See integration tests instead.
870- }
759+ }
0 commit comments