@@ -94,6 +94,8 @@ periodics:
94
94
env :
95
95
- name : " BOSKOS_HOST"
96
96
value : " boskos.test-pods.svc.cluster.local"
97
+ - name : " USER"
98
+ value : " periodic-k8s-containerd-conformance-job"
97
99
resources :
98
100
requests :
99
101
memory : " 5Gi"
@@ -112,20 +114,13 @@ periodics:
112
114
113
115
export PATH=$GOPATH/bin:$PATH
114
116
export GO111MODULE=on
115
-
117
+ source "./hack/boskos.sh"
116
118
117
119
make install-deployer-tf
118
120
TF_LATEST="v1.9.8"
119
-
120
121
RESOURCE_TYPE="powervs-k8s-conformance"
121
- USER="periodic-k8s-containerd-conformance-job"
122
-
123
- trap cleanup EXIT
124
122
125
- cleanup(){
126
- # stop the boskos heartbeat
127
- [[ -z ${HEART_BEAT_PID:-} ]] || kill -9 "${HEART_BEAT_PID}" || true
128
- }
123
+ trap 'cleanup ${HEART_BEAT_PID:-}' EXIT
129
124
130
125
curl -fsSL https://releases.hashicorp.com/terraform/${TF_LATEST:1}/terraform_${TF_LATEST:1}_linux_amd64.zip -o ./terraform.zip
131
126
unzip -o ./terraform.zip >/dev/null 2>&1
@@ -148,46 +143,32 @@ periodics:
148
143
TIMESTAMP=$(date +%s)
149
144
jq --arg key0 'k8s-build-version' --arg value0 $K8S_BUILD_VERSION '. | .[$key0]=$value0' <<<'{}' > $ARTIFACTS/metadata.json
150
145
151
-
152
146
set +o errexit
147
+ # If BOSKOS_HOST is set then acquire a resource from Boskos.
148
+ if [ -n "${BOSKOS_HOST:-}" ]; then
149
+ # Check out the resource from Boskos and store the produced environment
150
+ # variables in a temporary file.
151
+ account_env_var_file="$(mktemp)"
152
+ checkout_account ${RESOURCE_TYPE} 1> "${account_env_var_file}"
153
+ checkout_account_status="${?}"
153
154
154
- heartbeat_account(){
155
- count=0
156
- url="http://${BOSKOS_HOST}/update?name=${BOSKOS_RESOURCE_NAME}&state=busy&owner=${USER}"
157
- while [ ${count} -lt 120 ]
158
- do
159
- status_code=$(curl -s -o /dev/null -w '%{http_code}' -X POST ${url})
160
- if [[ ${status_code} != 200 ]]; then
161
- echo "Heart beat to resource '${BOSKOS_RESOURCE_NAME}' failed due to invalid response, status code: ${status_code}"
162
- exit 1
163
- fi
164
- count=$(( $count + 1 ))
165
- sleep 60
166
- done
167
- }
155
+ # If the checkout process was a success then load the
156
+ # environment variables into this process.
157
+ [ "${checkout_account_status}" = "0" ] && . "${account_env_var_file}"
168
158
169
- if [ -n "${BOSKOS_HOST:-}" ]; then
170
- set +o xtrace
171
- url="http://${BOSKOS_HOST}/acquire?type=${RESOURCE_TYPE}&state=free&dest=busy&owner=${USER}"
172
- output=$(curl -X POST ${url})
173
- [ $? = 0 ] && status_code=200
159
+ # Always remove the account environment variable file which
160
+ # could contain sensitive information.
161
+ rm -f "${account_env_var_file}"
174
162
175
- if [[ ${status_code} == 200 && ${output} =~ "failed" ]]; then
176
- echo "Failed to acquire resource from Boskos of type ${RESOURCE_TYPE}"
177
- exit 1
178
- elif [[ ${status_code} == 200 ]]; then
179
- export BOSKOS_RESOURCE_NAME=$(echo ${output} | jq -r '.name')
180
- export BOSKOS_REGION=$(echo ${output} | jq -r '.userdata["region"]')
181
- export BOSKOS_RESOURCE_ID=$(echo ${output} | jq -r '.userdata["service-instance-id"]')
182
- export BOSKOS_ZONE=$(echo ${output} | jq -r '.userdata["zone"]')
183
- rm -rf output.json
184
- else
185
- echo "Failed to acquire resource due to invalid response, status code : ${status_code}"
186
- exit 1
187
- fi
163
+ if [ ! "${checkout_account_status}" = "0" ]; then
164
+ echo "error getting account from boskos" 1>&2
165
+ exit "${checkout_account_status}"
166
+ fi
188
167
189
- heartbeat_account >> "$ARTIFACTS/boskos.log" 2>&1 &
190
- HEART_BEAT_PID=$(echo $!)
168
+ # Run the heart beat process to tell Boskos that we are still
169
+ # using the checked out resource periodically.
170
+ heartbeat_account >> "$ARTIFACTS/boskos.log" 2>&1 &
171
+ HEART_BEAT_PID=$(echo $!)
191
172
fi
192
173
193
174
set -o xtrace
@@ -226,14 +207,7 @@ periodics:
226
207
exit $rc2
227
208
fi
228
209
229
- if [ -n "${BOSKOS_HOST:-}" ]; then
230
- url="http://${BOSKOS_HOST}/release?name=${BOSKOS_RESOURCE_NAME}&dest=dirty&owner=${USER}"
231
- status_code=$(curl -w '%{http_code}' -X POST ${url})
232
- if [[ ${status_code} != 200 ]]; then
233
- echo "Failed to release resource: ${BOSKOS_RESOURCE_NAME}"
234
- exit 1
235
- fi
236
- fi
210
+ [ -z "${BOSKOS_HOST:-}" ] || release_account >> "$ARTIFACTS/boskos.log" 2>&1
237
211
238
212
- name : periodic-kubernetes-containerd-e2e-node-tests-ppc64le
239
213
labels :
0 commit comments