Skip to content

Commit 0a4597f

Browse files
committed
fix(scaletest/templates): fix bugs and improve debugging
1 parent b5e5b39 commit 0a4597f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

scaletest/templates/scaletest-runner/scripts/lib.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ end_phase() {
8282
phase=$(tail -n 1 "${SCALETEST_PHASE_FILE}" | grep "START:${phase_num}:" | cut -d' ' -f3-)
8383
if [[ -z ${phase} ]]; then
8484
log "BUG: Could not find start phase ${phase_num} in ${SCALETEST_PHASE_FILE}"
85-
exit 1
85+
return 1
8686
fi
8787
log "End phase ${phase_num}: ${phase}"
8888
echo "$(date -Ins) END:${phase_num}: ${phase}" >>"${SCALETEST_PHASE_FILE}"
@@ -132,6 +132,7 @@ annotate_grafana() {
132132
'{time: $time, tags: $tags | split(","), text: $text}' <<<'{}'
133133
)"
134134
if [[ ${DRY_RUN} == 1 ]]; then
135+
echo "FAKEID:${tags}:${text}:${start}" >>"${SCALETEST_STATE_DIR}/grafana-annotations"
135136
log "Would have annotated Grafana, data=${json}"
136137
return 0
137138
fi
@@ -171,23 +172,18 @@ annotate_grafana_end() {
171172
tags="${tags},${GRAFANA_EXTRA_TAGS}"
172173
fi
173174

174-
if [[ ${DRY_RUN} == 1 ]]; then
175-
log "Would have updated Grafana annotation (end=${end}): ${text} [${tags}]"
176-
return 0
177-
fi
178-
179175
if ! id=$(grep ":${tags}:${text}:${start}" "${SCALETEST_STATE_DIR}/grafana-annotations" | sort -n | tail -n1 | cut -d: -f1); then
180176
log "NOTICE: Could not find Grafana annotation to end: '${tags}:${text}:${start}', skipping..."
181177
return 0
182178
fi
183179

184-
log "Annotating Grafana (end=${end}): ${text} [${tags}]"
180+
log "Updating Grafana annotation (end=${end}): ${text} [${tags}, add=${GRAFANA_ADD_TAGS:-}]"
185181

186182
if [[ -n ${GRAFANA_ADD_TAGS:-} ]]; then
187183
json="$(
188184
jq -n \
189185
--argjson timeEnd "${end}" \
190-
--argjson tags "${tags},${GRAFANA_ADD_TAGS}" \
186+
--arg tags "${tags},${GRAFANA_ADD_TAGS}" \
191187
'{timeEnd: $timeEnd, tags: $tags | split(",")}'
192188
)"
193189
else
@@ -275,7 +271,7 @@ coder_pods() {
275271
fetch_coder_full() {
276272
if [[ -x "${SCALETEST_CODER_BINARY}" ]]; then
277273
log "Full Coder binary already exists at ${SCALETEST_CODER_BINARY}"
278-
return
274+
return 0
279275
fi
280276
ns=$(namespace)
281277
if [[ -z "${ns}" ]]; then
@@ -286,12 +282,12 @@ fetch_coder_full() {
286282
pods=$(coder_pods)
287283
if [[ -z ${pods} ]]; then
288284
log "Could not find coder pods!"
289-
return
285+
return 1
290286
fi
291287
pod=$(cut -d ' ' -f 1 <<<"${pods}")
292288
if [[ -z ${pod} ]]; then
293289
log "Could not find coder pod!"
294-
return
290+
return 1
295291
fi
296292
log "Fetching full Coder binary from ${pod}"
297293
# We need --retries due to https://github.com/kubernetes/kubernetes/issues/60140 :(
@@ -309,8 +305,8 @@ fetch_coder_full() {
309305
# com.coder.scaletest.status. It will overwrite the previous status.
310306
set_pod_status_annotation() {
311307
if [[ $# -ne 1 ]]; then
312-
log "must specify an annotation value"
313-
return
308+
log "BUG: Must specify an annotation value"
309+
return 1
314310
else
315311
maybedryrun "${DRY_RUN}" kubectl --namespace "$(namespace)" annotate pod "$(hostname)" "com.coder.scaletest.status=$1" --overwrite
316312
fi

scaletest/templates/scaletest-runner/scripts/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ for scenario in "${SCALETEST_PARAM_LOAD_SCENARIOS[@]}"; do
7373
maybedryrun "$DRY_RUN" sleep 10
7474
status=1
7575
;;
76+
77+
*)
78+
log "WARNING: Unknown load scenario: ${scenario}, skipping..."
79+
;;
7680
esac
7781
set -e
7882
if ((status > 0)); then

scaletest/templates/scaletest-runner/startup.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ gather_logs() {
7474
annotate_grafana "logs" "Gather logs"
7575
podsraw="$(
7676
kubectl -n coder-big get pods -l app.kubernetes.io/name=coder -o name
77-
kubectl -n coder-big get pods -l app.kubernetes.io/name=coder-provisioner -o name
78-
kubectl -n coder-big get pods -l app.kubernetes.io/name=coder-workspace -o name | grep "^pod/scaletest-"
77+
kubectl -n coder-big get pods -l app.kubernetes.io/name=coder-provisioner -o name || true
78+
kubectl -n coder-big get pods -l app.kubernetes.io/name=coder-workspace -o name | grep "^pod/scaletest-" || true
7979
)"
8080
mapfile -t pods <<<"${podsraw}"
8181
for pod in "${pods[@]}"; do
8282
pod_name="${pod#pod/}"
83-
kubectl -n coder-big logs "${pod}" --since="${SCALETEST_RUN_START_TIME}" >"${SCALETEST_LOGS_DIR}/${pod_name}.txt"
83+
kubectl -n coder-big logs "${pod}" --since-time="${SCALETEST_RUN_START_TIME}" >"${SCALETEST_LOGS_DIR}/${pod_name}.txt"
8484
done
8585
annotate_grafana_end "logs" "Gather logs"
8686
}

0 commit comments

Comments
 (0)