
###############################################################################
#
# HTCondor-CE JobRouter configuration file
#
# DO NOT EDIT THIS FILE!  It will be overwritten on upgrades.
# Instead, place a file in /etc/condor-ce/config.d to override defaults here.
#
###############################################################################

###############################################################################
# Job Router Config
###############################################################################

# Uncomment this line to help with debugging errors.
#JOB_ROUTER_DEBUG = D_FULLDEBUG

# Automatically add these to the submit file
# TODO: Doesn't seem to work with Condor-C ?
# APPEND_REQ_VANILLA = LastClientContact - time() < 30*$(MINUTE)
# LastClientContact = time()
# SUBMIT_EXPRS = LastClientContact

# The below script generates proper settings for JOB_ROUTER_DEFAULTS, merged
# with OSG environment variables (if present).  Anytime you reconfig the OSG,
# you will need to reconfig Condor-CE
LOCAL_CONFIG_FILE = /usr/share/condor-ce/condor_ce_router_defaults|

# Only route jobs for an up-to-date client
# NOTE: disabled because HTCondor-G appears to not set this properly
#JOB_ROUTER_SOURCE_JOB_CONSTRAINT = ((target.LastClientContact =?= UNDEFINED) || (target.LastClientContact - time() < 30*60)) && (target.CondorCE is True)
CLASSAD_USER_LIBS = @CMAKE_INSTALL_LIBDIR@/condor/libclassad_ce.so, @CMAKE_INSTALL_LIBDIR@/condor/libeval_rsl.so, $(CLASSAD_USER_LIBS)

# Only route jobs with a valid, non-expired proxy for either the vanilla or standard universe.
JOB_ROUTER_SOURCE_JOB_CONSTRAINT = (target.x509userproxysubject =!= UNDEFINED) && (target.x509UserProxyExpiration =!= UNDEFINED) && (time() < target.x509UserProxyExpiration) && (target.JobUniverse =?= 5 || target.JobUniverse =?= 1)

# Put jobs on hold if they meet any of the following requirements
# 1. Is missing a proxy subject or proxy expiration date.
# 2. Has an expired proxy
# 3. It has not been routed by the CE and is not a standard, vanilla, scheduler, or local job.
# 4. It has not been routed by the CE and has been idle for 30+ min
SYSTEM_PERIODIC_HOLD = (x509userproxysubject =?= UNDEFINED) || (x509UserProxyExpiration =?= UNDEFINED) || (time() > x509UserProxyExpiration) || (RoutedBy is null && JobUniverse =!= 1 && JobUniverse =!= 5 && JobUniverse =!= 7 && JobUniverse =!= 12) || ((JobStatus =?= 1 && CurrentTime - EnteredCurrentStatus > 1800) && RoutedToJobId is null && RoutedJob =!= true)

SYSTEM_PERIODIC_HOLD_REASON = \
   strcat("CE job in status ", JobStatus, \
     " put on hold by SYSTEM_PERIODIC_HOLD due to ", \
     ifThenElse(isUndefined(x509userproxysubject) || isUndefined(x509UserProxyExpiration),  "missing user proxy.", \
       ifThenElse(time() > x509UserProxyExpiration, "expired user proxy.", \
         ifThenElse(RoutedBy is null && JobUniverse =!= 1 && JobUniverse =!= 5 && JobUniverse =!= 7 && JobUniverse =!= 12, \
           "invalid job universe.", \
           "non-existent route or entry in JOB_ROUTER_ENTRIES." \
         ) \
       ) \
     ) \
   )

# Remove jobs that have been on hold for longer than 24 hrs
SYSTEM_PERIODIC_REMOVE = (JobStatus == 5 && CurrentTime - EnteredCurrentStatus > 3600*24)

SYSTEM_PERIODIC_REMOVE_REASON = \
   strcat("CE job removed by SYSTEM_PERIODIC_REMOVE due to ", \
     ifThenElse((JobStatus == 5 && CurrentTime - EnteredCurrentStatus > 3600*24), "being in the hold state for 24 hours.", \
       ifThenElse((JobStatus == 5 && isUndefined(RoutedToJobId)), "non-existent route or entry in JOB_ROUTER_ENTRIES.", \
         "input files missing." \
       ) \
     ) \
   )

# This attribute limits the max time of any job to 48 hours.
ROUTED_JOB_MAX_TIME = 2880

# More aggressive polling period for testing purposes
JOB_ROUTER_POLLING_PERIOD = 10

# The following setting will put history.* files into a Gratia directory;
# this allows us to join identity information for non-Condor batch sites.
PER_JOB_HISTORY_DIR = /var/lib/gratia/condorce_data

# Give the job router a unique name to distinguish the HTCondor-CE jobs from
# the site JobRouter jobs.
JOB_ROUTER_NAME = htcondor-ce

