@@ -26,7 +26,6 @@ use crate::STDERR_FILE_NAME;
2626use crate :: STDOUT_FILE_NAME ;
2727use crate :: TaskExecutionResult ;
2828use crate :: config:: Config ;
29- use crate :: config:: TaskResourceLimitBehavior ;
3029use crate :: path:: EvaluationPath ;
3130use crate :: v1;
3231
@@ -132,6 +131,28 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
132131 //
133132 // TODO ACF 2025-09-10: make the persistence of the tempdir configurable
134133 let container_temp_dir = TempDir :: new_in ( self . spawn_request . attempt_dir ( ) ) ?;
134+ let container_tmp_path = container_temp_dir. path ( ) . join ( "tmp" ) . to_path_buf ( ) ;
135+ tokio:: fs:: DirBuilder :: new ( )
136+ . recursive ( true )
137+ . create ( & container_tmp_path)
138+ . await
139+ . with_context ( || {
140+ format ! (
141+ "failed to create container /tmp directory at `{path}`" ,
142+ path = container_tmp_path. display( )
143+ )
144+ } ) ?;
145+ let container_var_tmp_path = container_temp_dir. path ( ) . join ( "var_tmp" ) . to_path_buf ( ) ;
146+ tokio:: fs:: DirBuilder :: new ( )
147+ . recursive ( true )
148+ . create ( & container_var_tmp_path)
149+ . await
150+ . with_context ( || {
151+ format ! (
152+ "failed to create container /var/tmp directory at `{path}`" ,
153+ path = container_var_tmp_path. display( )
154+ )
155+ } ) ?;
135156
136157 // Assemble the Apptainer invocation. We'll write out this command to the host
137158 // filesystem, and ultimately submit it as the command to run via LSF.
@@ -196,12 +217,12 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
196217 write ! (
197218 & mut apptainer_command,
198219 "--mount type=bind,src={},dst=/tmp " ,
199- container_temp_dir . path ( ) . join ( "tmp" ) . display( )
220+ container_tmp_path . display( )
200221 ) ?;
201222 write ! (
202223 & mut apptainer_command,
203224 "--mount type=bind,src={},dst=/var/tmp " ,
204- container_temp_dir . path ( ) . join ( "var_tmp" ) . display( )
225+ container_var_tmp_path . display( )
205226 ) ?;
206227 write ! (
207228 & mut apptainer_command,
@@ -233,6 +254,7 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
233254 apptainer_command_path. display( )
234255 )
235256 } ) ?;
257+ fs:: set_permissions ( & apptainer_command_path, Permissions :: from_mode ( 0o777 ) ) . await ?;
236258
237259 // The path for the LSF-level stdout and stderr. This primarily contains the job
238260 // report, as we redirect Apptainer and WDL output separately.
@@ -324,6 +346,9 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
324346 // the containerized command has completed.
325347 let bsub_result = bsub_child. wait ( ) . await ?;
326348
349+ // Hang onto the container tmp dir until execution is complete.
350+ drop ( container_temp_dir) ;
351+
327352 Ok ( TaskExecutionResult {
328353 // Under normal circumstances, the exit code of `bsub -K` is the exit code of its
329354 // command, and the exit code of `apptainer exec` is likewise the exit code of its
@@ -432,7 +457,20 @@ impl TaskExecutionBackend for LsfApptainerBackend {
432457 // TODO ACF 2025-09-11: set a hard memory limit with `bsub -M !`?
433458 let _max_memory = v1:: max_memory ( hints) ?. map ( |i| i as u64 ) ;
434459
435- let name = request. id ( ) [ 0 ..LSF_JOB_NAME_MAX_LENGTH ] . to_string ( ) ;
460+ // Truncate the request ID to fit in the LSF job name length limit.
461+ //
462+ // TODO ACF 2025-09-12: test to see whether LSF even accepts non-ascii job
463+ // names...
464+ let request_id = request. id ( ) ;
465+ let name = if request_id. len ( ) > LSF_JOB_NAME_MAX_LENGTH {
466+ request_id
467+ . chars ( )
468+ . take ( LSF_JOB_NAME_MAX_LENGTH )
469+ . collect :: < String > ( )
470+ } else {
471+ request_id. to_string ( )
472+ } ;
473+
436474 self . manager . send (
437475 LsfApptainerTaskRequest {
438476 engine_config : self . engine_config . clone ( ) ,
@@ -471,7 +509,7 @@ impl TaskExecutionBackend for LsfApptainerBackend {
471509#[ derive( Debug , Clone , serde:: Deserialize , serde:: Serialize ) ]
472510pub struct LsfApptainerBackendConfig {
473511 // TODO ACF 2025-09-12: add queue option for short tasks
474- queue : Option < String > ,
512+ pub queue : Option < String > ,
475513}
476514
477515impl LsfApptainerBackendConfig {
0 commit comments