Search code examples
linuxhpclsf

how to limit job submision depending on location or partition


I am wondering if there is a way to limit the job submission depending on the location where the submission was made in HPC.

Thing is, recently a storage for a scratch disk was added. So now I have two partitions.

  1. home directory
  2. scratch directory

I want all the HPC users are forced to submit their jobs only in scratch directory not in home directory.

HPC is operating LSF for job scheduler. So, can I have job submission (i.e. bsub) are controlled through LSF such that only jobs submitted under the scratch directory runs in HPC?

Thanks in advance.


Solution

  • I don't think there's a way to do this natively, but there is a way to customize LSF submission-time checks to reject jobs submitted from the wrong directory. Take a look at this documentation:

    https://www.ibm.com/support/knowledgecenter/en/SSWRJV_10.1.0/lsf_admin/chap_sub_exec_controls_lsf_admin.html

    In particular, what you want to do is define an esub script which checks for the appropriate submission CWD. Let's say you name your script esub.dircheck, it would look something like this:

    #!/bin/sh 
    
    # Reject if submission is under /home
    if [[ $PWD/ = /home/* ]]; then
       echo "Job submission from /home forbidden"
       exit $LSB_SUB_ABORT_VALUE 
    fi 
    

    Now you can place the esub.dircheck into $LSF_SERVERDIR (make sure it's executable by all). Finally, if you want the check to happen for every job submission, set the following parameter in lsf.conf:

    LSB_ESUB_METHOD=dircheck
    

    One final note: I'm just checking that PWD has home as a prefix in the code above, but you probably need to do something a bit more sophisticated if you want to make sure that the directory you're in is under /home because there could be symbolic links that gum up the prefix check. Take a look at this answer for details.