Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5198a2

Browse files
johnstcnmafredri
andauthored
feat(scaletest): annotate scaletest pod when scaletest is in progress (#10235)
This PR modifies the scaletest-runner template to add a pod annotation to the scaletest runner pod.The annotation key is set to com.coder.scaletest.phase and the annotation value is one of preparing, running, or complete.This will allow checking if a scaletest is in progress, and preventing any operations that would interrupt a running scaletest.Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
1 parent782c22a commite5198a2

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

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

Lines changed: 37 additions & 13 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"
@@ -247,37 +250,58 @@ set_appearance() {
247250
"${CODER_URL}/api/v2/appearance"
248251
}
249252

253+
namespace() {
254+
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace
255+
}
256+
coder_pods() {
257+
kubectl get pods \
258+
--namespace"$(namespace)" \
259+
--selector"app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \
260+
--output jsonpath='{.items[*].metadata.name}'
261+
}
262+
250263
# fetch_coder_full fetches the full (non-slim) coder binary from one of the coder pods
251264
# running in the same namespace as the current pod.
252265
fetch_coder_full() {
253266
if [[-x"${SCALETEST_CODER_BINARY}" ]];then
254267
log"Full Coder binary already exists at${SCALETEST_CODER_BINARY}"
255268
return
256269
fi
257-
local pod
258-
local namespace
259-
namespace=$(</var/run/secrets/kubernetes.io/serviceaccount/namespace)
260-
if [[-z"${namespace}" ]];then
270+
ns=$(namespace)
271+
if [[-z"${ns}" ]];then
261272
log"Could not determine namespace!"
262-
exit 1
273+
return 1
263274
fi
264-
log"Namespace from serviceaccount token is${namespace}"
265-
pod=$(kubectl get pods \
266-
--namespace"${namespace}" \
267-
--selector"app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \
268-
--output jsonpath='{.items[0].metadata.name}')
275+
log"Namespace from serviceaccount token is${ns}"
276+
pods=$(coder_pods)
277+
if [[-z${pods} ]];then
278+
log"Could not find coder pods!"
279+
return
280+
fi
281+
pod=$(cut -d'' -f 1<<<"${pods}")
269282
if [[-z${pod} ]];then
270283
log"Could not find coder pod!"
271-
exit 1
284+
return
272285
fi
273286
log"Fetching full Coder binary from${pod}"
274287
# We need --retries due to https://github.com/kubernetes/kubernetes/issues/60140 :(
275288
maybedryrun"${DRY_RUN}" kubectl \
276-
--namespace"${namespace}" \
289+
--namespace"${ns}" \
277290
cp \
278291
--container coder \
279292
--retries 10 \
280293
"${pod}:/opt/coder""${SCALETEST_CODER_BINARY}"
281294
maybedryrun"${DRY_RUN}" chmod +x"${SCALETEST_CODER_BINARY}"
282295
log"Full Coder binary downloaded to${SCALETEST_CODER_BINARY}"
283296
}
297+
298+
# set_pod_status_annotation annotates the currently running pod with the key
299+
# com.coder.scaletest.status. It will overwrite the previous status.
300+
set_pod_status_annotation() {
301+
if [[$#-ne 1 ]];then
302+
log"must specify an annotation value"
303+
return
304+
else
305+
maybedryrun"${DRY_RUN}" kubectl --namespace"$(namespace)" annotate pod"$(hostname)""com.coder.scaletest.status=$1" --overwrite
306+
fi
307+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ coder exp scaletest create-workspaces \
1717
--count"${SCALETEST_PARAM_NUM_WORKSPACES}" \
1818
--template"${SCALETEST_PARAM_TEMPLATE}" \
1919
--concurrency"${SCALETEST_PARAM_CREATE_CONCURRENCY}" \
20+
--timeout 5h \
2021
--job-timeout 5h \
2122
--no-cleanup \
2223
--output json:"${SCALETEST_RESULTS_DIR}/create-workspaces.json"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp