11#! /bin/bash -x
22
3+ APPTAINER_BIN=/cvmfs/oasis.opensciencegrid.org/mis/apptainer/bin/apptainer
34OSP_TOKEN_PATH=/tmp/token
5+ CONDOR_LOGDIR=/pilot/log
46COMMON_DOCKER_ARGS=" run --user osg
57 --detach
68 --security-opt apparmor=unconfined
@@ -20,21 +22,32 @@ SINGULARITY_OUTPUT=$(mktemp)
2022PILOT_DIR=$( mktemp -d)
2123function start_singularity_backfill {
2224 useradd -mG docker testuser
23- singularity=/cvmfs/oasis.opensciencegrid.org/mis/apptainer/bin/apptainer
2425 echo -n " Singularity version is: "
25- $singularity version
26+ $APPTAINER_BIN version
2627 chown testuser: $SINGULARITY_OUTPUT $PILOT_DIR
28+
29+ su - testuser -c \
30+ " $APPTAINER_BIN instance start \
31+ -B /cvmfs \
32+ -B /dev/fuse \
33+ -B $PILOT_DIR :/pilot \
34+ -ci \
35+ docker-daemon:$CONTAINER_IMAGE \
36+ backfill"
37+
38+ ret=$?
39+ [[ $ret -eq $ABORT_CODE ]] && return $ABORT_CODE
40+
2741 su - testuser -c \
2842 " APPTAINERENV_TOKEN=None \
2943 APPTAINERENV_GLIDEIN_Site=None \
3044 APPTAINERENV_GLIDEIN_ResourceName=None \
3145 APPTAINERENV_GLIDEIN_Start_Extra=True \
32- $singularity \
33- run \
34- -B /cvmfs \
35- -B $PILOT_DIR :/pilot \
36- -cip \
37- docker-daemon:$CONTAINER_IMAGE > $SINGULARITY_OUTPUT 2>&1 &"
46+ $APPTAINER_BIN exec instance://backfill /usr/local/sbin/supervisord_startup.sh > $SINGULARITY_OUTPUT 2>&1 &"
47+
48+ ret=$?
49+ [[ $ret -eq $ABORT_CODE ]] && cat " $SINGULARITY_OUTPUT "
50+ return $ret
3851}
3952
4053function start_docker_backfill {
@@ -112,32 +125,21 @@ function wait_for_output {
112125function test_docker_startup {
113126 print_test_header " Testing container startup"
114127
115- logfile=$( wait_for_output 600 run_inside_backfill_container find /pilot -name StartLog -size +1) ; ret=$?
128+ # Wait for the startd to be ready
129+ # N.B. we have condor dump the eval'ed STARTD_State expression
130+ # because `condor_who -wait` always returns 0
131+ startd_ready=$( run_inside_backfill_container condor_who -log " $CONDOR_LOGDIR " \
132+ -wait:120 ' IsReady && STARTD_State =?= "Ready"' \
133+ -af ' STARTD_State =?= "Ready"' )
134+ ret=$?
135+
116136 if [[ $ret -eq $ABORT_CODE ]]; then
117- echo >&2 " Container check failed, aborting"
118137 debug_docker_backfill
119138 return $ABORT_CODE
120139 fi
121140
122- if [[ -z $logfile ]]; then
123- debug_docker_backfill
124- return 1
125- fi
126-
127- wait_for_output 60 \
128- run_inside_backfill_container \
129- grep \
130- -- \
131- ' Changing activity: Benchmarking -> Idle' \
132- $logfile ; ret=$?
133- if [[ $ret != 0 ]]; then
134- run_inside_backfill_container tail -n 400 $logfile
135- if [[ $ret -eq $ABORT_CODE ]]; then
136- debug_docker_backfill
137- return $ABORT_CODE
138- else
139- return 1
140- fi
141+ if [[ $startd_ready != " true" ]]; then
142+ run_inside_backfill_container tail -n 400 " $CONDOR_LOGDIR /StartLog"
141143 fi
142144}
143145
@@ -154,9 +156,7 @@ function test_docker_HAS_SINGULARITY {
154156 direct=" -direct"
155157 fi
156158
157- logdir=$( run_inside_backfill_container find /pilot -type d -name log) ; ret=$?
158- [[ $ret -eq $ABORT_CODE ]] && { debug_docker_backfill; return $ABORT_CODE ; }
159- startd_addr=$( run_inside_backfill_container condor_who -log $logdir -dae | awk ' /^Startd/ {print $6}' ) ; ret=$?
159+ startd_addr=$( run_inside_backfill_container condor_who -log $CONDOR_LOGDIR -dae | awk ' /^Startd/ {print $6}' ) ; ret=$?
160160 [[ $ret -eq $ABORT_CODE ]] && { debug_docker_backfill; return $ABORT_CODE ; }
161161 echo " startd addr: $startd_addr "
162162 has_singularity=$( run_inside_backfill_container \
@@ -175,18 +175,20 @@ function test_docker_HAS_SINGULARITY {
175175function test_singularity_startup {
176176 print_test_header " Testing container startup"
177177
178- logfile=$( wait_for_output 1200 find $PILOT_DIR -name StartLog -size +1)
179- if [[ -z $logfile ]]; then
178+ # Wait for the startd to be ready
179+ # N.B. we have condor dump the eval'ed STARTD_State expression
180+ # because `condor_who -wait` always returns 0
181+ startd_ready=$( su - testuser -c \
182+ " $APPTAINER_BIN exec instance://backfill \
183+ condor_who -log $CONDOR_LOGDIR \
184+ -wait:120 'IsReady && STARTD_State =?= \" Ready\" ' \
185+ -af 'STARTD_State =?= \" Ready\" '" )
186+
187+ if [[ $startd_ready != " true" ]]; then
180188 cat $SINGULARITY_OUTPUT
189+ cat " $CONDOR_LOGDIR /StartLog"
181190 return 1
182191 fi
183-
184- wait_for_output 60 \
185- grep \
186- -- \
187- ' Changing activity: Benchmarking -> Idle' \
188- $logfile \
189- || (tail -n 400 $logfile && return 1)
190192}
191193
192194function test_singularity_HAS_SINGULARITY {
0 commit comments