Skip to content

Commit 8ed96d5

Browse files
committed
address PR feedback
1 parent c19a0f5 commit 8ed96d5

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ show_json() {
4040
set_status() {
4141
dry_run=
4242
if [[ ${DRY_RUN} == 1 ]]; then
43-
dry_run=" (dry-ryn)"
43+
dry_run=" (dry-run)"
4444
fi
4545
prev_status=$(get_status)
4646
if [[ ${prev_status} != *"Not started"* ]]; then
@@ -49,6 +49,9 @@ set_status() {
4949
echo "$(date -Ins) ${*}${dry_run}" >>"${SCALETEST_STATE_DIR}/status"
5050

5151
annotate_grafana "status" "Status: ${*}"
52+
53+
status_lower=$(tr '[:upper:]' '[:lower:]' <<<"${*}")
54+
set_pod_status_annotation "${status_lower}"
5255
}
5356
lock_status() {
5457
chmod 0440 "${SCALETEST_STATE_DIR}/status"
@@ -248,17 +251,13 @@ set_appearance() {
248251
}
249252

250253
namespace() {
251-
local ns
252-
ns=$(</var/run/secrets/kubernetes.io/serviceaccount/namespace)
253-
echo "${ns}"
254+
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace
254255
}
255256
coder_pods() {
256-
local pods
257-
pods=$(kubectl get pods \
257+
kubectl get pods \
258258
--namespace "$(namespace)" \
259259
--selector "app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \
260-
--output jsonpath='{.items[*].metadata.name}')
261-
echo "${pods}"
260+
--output jsonpath='{.items[*].metadata.name}'
262261
}
263262

264263
# fetch_coder_full fetches the full (non-slim) coder binary from one of the coder pods
@@ -271,18 +270,18 @@ fetch_coder_full() {
271270
ns=$(namespace)
272271
if [[ -z "${ns}" ]]; then
273272
log "Could not determine namespace!"
274-
exit 1
273+
return
275274
fi
276275
log "Namespace from serviceaccount token is ${ns}"
277276
pods=$(coder_pods)
278277
if [[ -z ${pods} ]]; then
279278
log "Could not find coder pods!"
280-
exit 1
279+
return
281280
fi
282-
pod=$(echo "${pods}" | cut -d ' ' -f 1)
281+
pod=$(cut -d ' ' -f 1 <<<"${pods}")
283282
if [[ -z ${pod} ]]; then
284283
log "Could not find coder pod!"
285-
exit 1
284+
return
286285
fi
287286
log "Fetching full Coder binary from ${pod}"
288287
# We need --retries due to https://github.com/kubernetes/kubernetes/issues/60140 :(
@@ -296,12 +295,12 @@ fetch_coder_full() {
296295
log "Full Coder binary downloaded to ${SCALETEST_CODER_BINARY}"
297296
}
298297

299-
# set_status_annotation annotates the currently running pod with the key
298+
# set_pod_status_annotation annotates the currently running pod with the key
300299
# com.coder.scaletest.status. It will overwrite the previous status.
301-
set_status_annotation() {
300+
set_pod_status_annotation() {
302301
if [[ $# -ne 1 ]]; then
303302
log "must specify an annotation value"
304-
exit 1
303+
return
305304
else
306305
maybedryrun "${DRY_RUN}" kubectl --namespace "$(namespace)" annotate pod "$(hostname)" "com.coder.scaletest.status=$2" --overwrite
307306
fi

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mkdir -p "${SCALETEST_RESULTS_DIR}"
1111

1212
log "Preparing scaletest workspace environment..."
1313
set_status Preparing
14-
set_status_annotation preparing
1514

1615
log "Compressing previous run logs (if applicable)..."
1716
mkdir -p "${HOME}/archive"

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export SCALETEST_PARAM_LOAD_SCENARIOS=("${scaletest_load_scenarios[@]}")
1111

1212
log "Running scaletest..."
1313
set_status Running
14-
set_status_annotation running
1514

1615
start_phase "Creating workspaces"
1716
coder exp scaletest create-workspaces \
@@ -64,4 +63,3 @@ done
6463

6564
log "Scaletest complete!"
6665
set_status Complete
67-
set_status_annotation completed

0 commit comments

Comments
 (0)