-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathparrot_setup
More file actions
executable file
·206 lines (165 loc) · 7.19 KB
/
parrot_setup
File metadata and controls
executable file
·206 lines (165 loc) · 7.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/sh
glidein_config="$1"
function warn {
echo `date` parrot_setup: $@ 1>&2
}
function die {
errorType="$1"
shift
warn ERROR: "$@"
"$error_gen" -error parrot_setup "$errorType" "$@"
exit 1
}
###########################################################
# import add_config_line and add_condor_vars_line functions
add_config_line_source=`grep '^ADD_CONFIG_LINE_SOURCE ' $glidein_config | awk '{print $2}'`
source $add_config_line_source
condor_vars_file=`grep -i "^CONDOR_VARS_FILE " $glidein_config | awk '{print $2}'`
# find error reporting helper script
error_gen=`grep '^ERROR_GEN_PATH ' $glidein_config | awk '{print $2}'`
# Is there a better way to find parrot_cfg?
parrot_cfg=$(find $(pwd) -name parrot_cfg)
if [ "$parrot_cfg" = "" ] || ! [ -f "$parrot_cfg" ]; then
die VO_Config "No parrot_cfg found under `pwd`"
fi
add_config_line PARROT_CFG "$parrot_cfg"
. "$parrot_cfg"
# find the unpacked parrot.tgz tarball location
# this case is for <file> in the top-level scope of the frontend config
GLIDEIN_PARROT=`grep -i "^GLIDECLIENT_GLIDEIN_PARROT " $glidein_config | awk '{print $2}'`
if [ -z "$GLIDEIN_PARROT" ]; then
# this case is for <file> in the group scope of the frontend config
GLIDEIN_PARROT=`grep -i "^GLIDECLIENT_GROUP_GLIDEIN_PARROT " $glidein_config | awk '{print $2}'`
fi
if [ -z "$GLIDEIN_PARROT" ]; then
# this case is for <file> in the factory config
GLIDEIN_PARROT=`grep -i "^GLIDEIN_PARROT " $glidein_config | awk '{print $2}'`
fi
if [ -z "$GLIDEIN_PARROT" ]; then
die VO_Config "No GLIDECLIENT_GLIDEIN_PARROT or GLIDECLIENT_GROUP_GLIDEIN_PARROT found in glidein config. This could indicate that parrot.tgz was not included in the glidein files or absdir_outattr for this tarball was not set to GLIDEIN_PARROT."
fi
# untar location GLIDECLIENT_GLIDEIN_PARROT is directory containing untarred files
# point GLIDEIN_PARROT inside the directory contained within the tar file:
GLIDEIN_PARROT="$GLIDEIN_PARROT/parrot"
add_config_line GLIDEIN_PARROT "$GLIDEIN_PARROT"
# Unfortunately, the user can override GLIDEIN_PARROT and manipulate
# the wrapper, so instead of passing it to cvmfs_job_wrapper via the
# environment, we assume _CONDOR_SCRATCH_DIR will be a
# sub-(sub)-directory of the directory containing the following
# symlink:
ln -s $GLIDEIN_PARROT $(dirname $glidein_config)/GLIDEIN_PARROT
# configure CVMFS
# load balance across central proxies, if we use them
central_cvmfs_proxies="$CVMFS_PROXIES"
site_proxy=`grep -i "^PROXY_URL " $glidein_config | awk '{print $2}'`
if [ "$site_proxy" = "None" ]; then
site_proxy=""
fi
if [ "$site_proxy" != "" ]; then
warn "((((((((((((((((((((((((((("
warn "Testing access to $CVMFS_TEST_REPO via proxy $site_proxy"
wget_succeeded=0
for attempt in 1 2 3; do
if [ $attempt -gt 1 ]; then
sleep 1
fi
wget_output=$(env http_proxy="$site_proxy" wget -qdO /dev/null $CVMFS_TEST_REPO/.cvmfspublished 2>&1)
wget_rc=$?
echo "$wget_output"
age=$(echo "$wget_output" | grep '^Age: *[1-9]')
if [ "$wget_rc" != "0" ]; then
warn "WARNING: proxy $http_proxy did NOT succeed in wget test, so not using it"
break
elif [ "$age" != "" ]; then
warn "proxy $http_proxy succeeded in wget test"
wget_succeeded=1
break
else
# this could mean the file was not already cached or the proxy does
# not cache, so try 3 times before giving up
warn "proxy $http_proxy retrieved file but non-zero age not detected (attempt $attempt): $age"
fi
done
if [ $wget_succeeded != 1 ]; then
warn "WARNING: will not use proxy $http_proxy for CVMFS, using central proxies instead"
site_proxy=""
fi
warn ")))))))))))))))))))))))))))"
fi
if [ "$site_proxy" != "" ]; then
# only fail-over to central proxies if site proxy fails
cvmfs_proxies="proxies=$site_proxy;$central_cvmfs_proxies"
else
# no site proxy
cvmfs_proxies="proxies=$central_cvmfs_proxies"
fi
# append cvmfs_proxies option to each of the repos defined in PARROT_CVMFS_REPO
REPO_WITH_CACHE=""
for repo in ${PARROT_CVMFS_REPO}; do
if [ "$REPO_WITH_CACHE" != "" ]; then
REPO_WITH_CACHE="${REPO_WITH_CACHE} "
fi
REPO_WITH_CACHE="${REPO_WITH_CACHE}${repo},${cvmfs_proxies}"
done
PARROT_CVMFS_REPO="${REPO_WITH_CACHE}"
PARROT_CVMFS_REPO=$(echo "$PARROT_CVMFS_REPO" | sed "s|GLIDEIN_PARROT_DIR|$GLIDEIN_PARROT|g")
export PARROT_CVMFS_REPO
echo "export PARROT_CVMFS_REPO=\"${PARROT_CVMFS_REPO}\"" > $GLIDEIN_PARROT/setup.sh \
|| die WN_Resource "failed to create parrot/setup.sh"
# Copy optional parrot options from parrot_cfg to the glidein config file
if ! [ -z "$GLIDEIN_PARROT_OPTIONS" ]; then
echo "GLIDEIN_PARROT_OPTIONS=\"${GLIDEIN_PARROT_OPTIONS}\"" \
>> $GLIDEIN_PARROT/setup.sh \
|| die WN_Resource "failed to append to parrot/setup.sh"
fi
if ! [ -z "$GlideinUseParrotIDBox" ]; then
echo "GlideinUseParrotIDBox=\"${GlideinUseParrotIDBox}\"" \
>> $GLIDEIN_PARROT/setup.sh \
|| die WN_Resource "failed to append to parrot/setup.sh"
fi
if [ "$GlideinAllowSwitchingCVMFSRepositories" != "false" ]; then
echo "export PARROT_ALLOW_SWITCHING_CVMFS_REPOSITORIES=1" >> $GLIDEIN_PARROT/setup.sh \
|| die WN_Resource "failed to append to parrot/setup.sh"
fi
if [ "$CVMFS_OSG_APP" != "" ]; then
# add CVMFS_OSG_APP to the job wrapper environment
add_config_line CVMFS_OSG_APP $CVMFS_OSG_APP
add_condor_vars_line CVMFS_OSG_APP "S" "-" "+" "N" "N" "+"
fi
FORCE_PARROT=0
if [ "$GlideinAlwaysUseParrotWrapper" != "" ] && [ "$GlideinAlwaysUseParrotWrapper" != "false" ]; then
# The wrapper script will check for this file to see if it should always apply the parrot wrapper
touch $GLIDEIN_PARROT/FORCE_PARROT
fi
warn "Attempting to run parrot_run and testing for existence of $CVMFS_TEST_PATH"
parrot_tmp="${GLIDEIN_PARROT}/tmp1"
if "$GLIDEIN_PARROT/parrot_run" -d cvmfs -t "$parrot_tmp" test -e $CVMFS_TEST_PATH; then
# publish in the machine ad that this glidein supports parrot CVMFS
add_condor_vars_line HasParrotCVMFS "C" "True" "+" "N" "Y" "-"
else
warn "test of parrot_run failed with exit status $?."
# do a simple wget test to see if that also fails
for http_proxy in `echo $cvmfs_proxies | sed 's/^proxies=//;s/[;|]/ /g;s|http://||g'`; do
export http_proxy
warn "((((((((((((((((((((((((((("
warn "Testing access to $CVMFS_TEST_REPO via proxy $http_proxy"
wget -O /dev/null $CVMFS_TEST_REPO/.cvmfspublished
if [ "$?" != "0" ]; then
warn "FAILURE: proxy $http_proxy did NOT succeed in wget test"
else
warn "proxy $http_proxy succeeded in wget test"
fi
warn ")))))))))))))))))))))))))))"
done
if [ "$GlideinRequiresParrotCVMFS" != "" ] && [ "$GlideinRequiresParrotCVMFS" != "false" ]; then
die WN_Resource "aborting glidein setup, because parrot setup failed and was required"
fi
# Do not let jobs requiring CVMFS run here
GLIDECLIENT_Start=`grep -i "^GLIDECLIENT_Start " $glidein_config | cut -d " " -f 2-`
if [ "$GLIDECLIENT_Start" != "" ]; then
GLIDECLIENT_Start="($GLIDECLIENT_Start) && "
fi
GLIDECLIENT_Start="${GLIDECLIENT_Start}TARGET.RequiresCVMFS=!=True"
add_config_line GLIDECLIENT_Start "$GLIDECLIENT_Start"
fi
"$error_gen" -ok parrot_setup