Newer
Older
#!/bin/bash
# Usage: check-lsst-job-env.sh
# Init
thisScript=$(basename $0)
Fabio Hernandez
committed
# Display the execution environment before running the LSST local prolog.
echo -e "\nBefore running local prolog:"
/usr/bin/printenv
# Ensure the variable LSST_LOCAL_PROLOG is set and source the script it
# refers to.
if [[ -z ${LSST_LOCAL_PROLOG} ]]; then
echo "ERROR: variable LSST_LOCAL_PROLOG is not set"
exit 1
fi
source ${LSST_LOCAL_PROLOG}
Fabio Hernandez
committed
# Examine the environment set by the local prolog.
echo -e "\nAfter running local prolog:"
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# The environment variables below must be set. Their associated value is
# "true" if they refer to an existing file which we must check for existance.
declare -A envVars=(
# PanDA
['GOOGLE_APPLICATION_CREDENTIALS']="true"
['AWS_SHARED_CREDENTIALS_FILE']="true"
['USE_REALTIME_LOGGING']="false"
['REALTIME_LOGGING_SERVER']="false"
['REALTIME_LOGNAME']="false"
['REALTIME_LOGFILES']="false"
['LSST_RUN_TEMP_SPACE']="true"
# Butler
['X509_USER_PROXY']="true"
['LSST_HTTP_AUTH_CLIENT_CERT']="true"
['LSST_HTTP_AUTH_CLIENT_KEY']="true"
['LSST_RESOURCES_TMPDIR']="true"
['LSST_HTTP_PUT_SEND_EXPECT_HEADER']="false"
['LSST_DB_AUTH']="true"
['LSST_HTTP_CACERT_BUNDLE']="true"
['DAF_BUTLER_REPOSITORY_INDEX']="true"
)
for var in ${!envVars[@]}; do
value=${!var}
if [[ -z ${value} ]]; then
echo "ERROR: ${var} is not set"
else
echo "OK: ${var} is set to \"${value}\" "
# If this variable points to a path, check that path exists
isPath=${envVars[${var}]}
if [[ ${isPath} == "true" ]]; then
path=${value}
if [[ ! -e ${path} ]] && [[ ! -d ${path} ]]; then
echo "ERROR: path ${path} does not exist"
else
echo "OK: ${var} points to valid path \"${path}\" "
fi
fi
fi
done
# Check the butler repos pointed to by DAF_BUTLER_REPOSITORY_INDEX exist and
# can actually be used by the 'butler' command.
if [[ -n ${DAF_BUTLER_REPOSITORY_INDEX} ]]; then
releaseDir=$(ls -dr /cvmfs/sw.lsst.eu/linux-x86_64/lsst_distrib/w* | head -1)
source "${releaseDir}/loadLSST.bash" && setup lsst_distrib
repos=$(awk '/^[[:alnum:]_\-]+:/ {printf "%s\n", $1}' ${DAF_BUTLER_REPOSITORY_INDEX} | sed 's/://g')
for repo in ${repos}; do
echo -e "\nquerying repo \"${repo}\""
butler query-dimension-records ${repo} instrument
if [[ $? != 0 ]]; then
echo "ERROR: could not access butler repo ${repo}"
fi
done
fi
echo -e "\n"
# Run epilog and check no clean up was made to avoid modifying execution
# environment of other PanDA pilot jobs running in the same Slurm job.
if [[ -z ${LSST_LOCAL_EPILOG} ]]; then
echo "ERROR: variable LSST_LOCAL_EPILOG is not set"
exit 1
fi
source ${LSST_LOCAL_EPILOG}
if [[ ! -f ${DAF_BUTLER_REPOSITORY_INDEX} ]] ; then
echo "ERROR: after epilog, the butler repository index ${DAF_BUTLER_REPOSITORY_INDEX} should still exist but doesn't"
fi