Skip to content

Commit

Permalink
Move the default values of some environment variables into the Docker…
Browse files Browse the repository at this point in the history
…file; use better booleans
  • Loading branch information
matyasselmeci committed Mar 20, 2023
1 parent 6c51809 commit f1c8545
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
33 changes: 15 additions & 18 deletions 10-setup-htcondor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ set_var() {
return 0
}


# explicitly true:
# y(es), t(rue), 1, on; uppercase or lowercase
is_true () {
case "${1:-0}" in
# y(es), t(rue), 1, on; uppercase or lowercase
[yY]*|[tT]*|1|[Oo][Nn]) return 0 ;;
*) return 1 ;;
case "${1^^}" in # bash-ism to uppercase the var
Y|YES) return 0 ;;
T|TRUE) return 0 ;;
ON) return 0 ;;
1) return 0 ;;
esac
return 1
}

random_range () {
Expand Down Expand Up @@ -131,15 +134,6 @@ if [ "x$GLIDEIN_Start_Extra" != "x" ]; then
else
export GLIDEIN_Start_Extra="True"
fi
if [ "x$ACCEPT_JOBS_FOR_HOURS" = "x" ]; then
export ACCEPT_JOBS_FOR_HOURS=336
fi
if [ "x$ACCEPT_IDLE_MINUTES" = "x" ]; then
export ACCEPT_IDLE_MINUTES=30
fi
if [ "x$ALLOW_CPUJOB_ON_GPUSLOT" = "x" ]; then
export ALLOW_CPUJOB_ON_GPUSLOT="0"
fi


#
Expand Down Expand Up @@ -368,7 +362,7 @@ default_image_executable=${script_exec_prefix}osgvo-default-image
singularity_extras_lib=${script_lib_prefix}singularity-extras
ospool_lib=${script_lib_prefix}ospool-lib

if [[ $CONTAINER_PILOT_USE_JOB_HOOK && ! -e ${prepare_hook} ]]; then
if is_true $CONTAINER_PILOT_USE_JOB_HOOK && [[ ! -e ${prepare_hook} ]]; then
echo >&2 "CONTAINER_PILOT_USE_JOB_HOOK requested but job hook not found at ${prepare_hook}"
exit 1
fi
Expand Down Expand Up @@ -452,7 +446,7 @@ fi

# some admins prefer to reserve gpu slots for gpu jobs, others
# want to run cpu jobs if there are no gpu jobs available
if [[ $ALLOW_CPUJOB_ON_GPUSLOT = "1" ]]; then
if is_true "$ALLOW_CPUJOB_ON_GPUSLOT"; then
echo "CPUJOB_ON_GPUSLOT = True" >> "$PILOT_CONFIG_FILE"
else
echo "CPUJOB_ON_GPUSLOT = ifThenElse(MY.TotalGPUs > 0 && MY.GPUs > 0, TARGET.RequestGPUs > 0, True)" >> "$PILOT_CONFIG_FILE"
Expand Down Expand Up @@ -489,7 +483,7 @@ cd $LOCAL_DIR

# gwms files in the correct location
cp -a /gwms/. $LOCAL_DIR/
if [[ $CONTAINER_PILOT_USE_JOB_HOOK ]]; then
if is_true $CONTAINER_PILOT_USE_JOB_HOOK; then
cp -a ${simple_job_wrapper} condor_job_wrapper.sh
else
cp -a ${osgvo_singularity_wrapper} condor_job_wrapper.sh
Expand All @@ -503,7 +497,10 @@ export condor_vars_file=$LOCAL_DIR/main/condor_vars.lst
if [[ -z $OSG_DEFAULT_CONTAINER_DISTRIBUTION ]]; then
OSG_DEFAULT_CONTAINER_DISTRIBUTION="30%__opensciencegrid/osgvo-el7:latest 70%__opensciencegrid/osgvo-el8:latest"
fi
if [[ -z $SINGULARITY_DISABLE_PID_NAMESPACES ]]; then
# The glidein config expects a 1 or a 0
if is_true "$SINGULARITY_DISABLE_PID_NAMESPACES"; then
SINGULARITY_DISABLE_PID_NAMESPACES=1
else
SINGULARITY_DISABLE_PID_NAMESPACES=0
fi
cat >$glidein_config <<EOF
Expand Down
24 changes: 16 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,29 @@ ENV CVMFS_HTTP_PROXY=
# The quota limit in MB for CVMFS; leave this blank to use the default
ENV CVMFS_QUOTA_LIMIT=

# How many hours to accept new jobs for
ENV ACCEPT_JOBS_FOR_HOURS=336
# Minutes to wait before shutting down due to lack of jobs
ENV ACCEPT_IDLE_MINUTES=30

# Set this to restrict this pilot to only run jobs from a specific Project
ENV OSG_PROJECT_NAME=

# Additional restrictions for your START expression
ENV GLIDEIN_Start_Extra=

# Clear this to not use the prepare-job-hook to run Singularity jobs
ENV CONTAINER_PILOT_USE_JOB_HOOK=1
# Allow CPU jobs on GPU slots if there are GPUs left
ENV ALLOW_CPUJOB_ON_GPUSLOT=false

# Use the prepare-job-hook to run Singularity jobs
ENV CONTAINER_PILOT_USE_JOB_HOOK=true

# Set this to 1 to add a random string in the NETWORK_HOSTNAME (useful if running multiple containers with the same actual hostname)
ENV GLIDEIN_RANDOMIZE_NAME=
# Add a random string in the NETWORK_HOSTNAME (useful if running multiple containers with the same actual hostname)
ENV GLIDEIN_RANDOMIZE_NAME=false

# Set this to empty to not send syslog remotely
ENV ENABLE_REMOTE_SYSLOG=1
# Send pilot and condor logs to a central syslog server
ENV ENABLE_REMOTE_SYSLOG=true

# Set this to "1" to use ITB versions of scripts and connect to the ITB pool
ENV ITB=
# Use ITB versions of scripts and connect to the ITB pool
ENV ITB=false

0 comments on commit f1c8545

Please sign in to comment.