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

Commit8ffe0e2

Browse files
authored
feat(scaletest/templates): gather pod logs at the end of a scale test (#10288)
1 parent8efa123 commit8ffe0e2

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

‎scaletest/templates/scaletest-runner/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ locals {
4242
cpu=16
4343
memory=64
4444
home_disk_size=10
45-
scaletest_run_id="scaletest-${time_static.start_time.rfc3339}"
45+
scaletest_run_id="scaletest-${replace(time_static.start_time.rfc3339,":","-")}"
4646
scaletest_run_dir="/home/coder/${local.scaletest_run_id}"
47+
scaletest_run_start_time=time_static.start_time.rfc3339
4748
grafana_url="https://stats.dev.c8s.io"
4849
grafana_dashboard_uid="qLVSTR-Vz"
4950
grafana_dashboard_name="coderv2-loadtest-dashboard"
@@ -374,6 +375,7 @@ resource "coder_agent" "main" {
374375
# Local envs passed as arguments to `coder exp scaletest` invocations.
375376
SCALETEST_RUN_ID: local.scaletest_run_id,
376377
SCALETEST_RUN_DIR: local.scaletest_run_dir,
378+
SCALETEST_RUN_START_TIME: local.scaletest_run_start_time,
377379

378380
# Comment is a scaletest param, but we want to surface it separately from
379381
# the rest, so we use a different name.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ SCALETEST_STATE_DIR="${SCALETEST_RUN_DIR}/state"
1919
SCALETEST_PHASE_FILE="${SCALETEST_STATE_DIR}/phase"
2020
# shellcheck disable=SC2034
2121
SCALETEST_RESULTS_DIR="${SCALETEST_RUN_DIR}/results"
22+
SCALETEST_LOGS_DIR="${SCALETEST_RUN_DIR}/logs"
2223
SCALETEST_PPROF_DIR="${SCALETEST_RUN_DIR}/pprof"
2324
# https://github.com/kubernetes/kubernetes/issues/72501 :-(
24-
SCALETEST_CODER_BINARY="/tmp/coder-full-${SCALETEST_RUN_ID//:/-}"
25+
SCALETEST_CODER_BINARY="/tmp/coder-full-${SCALETEST_RUN_ID}"
2526

26-
mkdir -p"${SCALETEST_STATE_DIR}""${SCALETEST_RESULTS_DIR}""${SCALETEST_PPROF_DIR}"
27+
mkdir -p"${SCALETEST_STATE_DIR}""${SCALETEST_RESULTS_DIR}""${SCALETEST_LOGS_DIR}""${SCALETEST_PPROF_DIR}"
2728

2829
coder() {
2930
if [[!-x"${SCALETEST_CODER_BINARY}" ]];then

‎scaletest/templates/scaletest-runner/startup.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ annotate_grafana "workspace" "Agent running" # Ended in shutdown.sh.
6363
}&
6464
pprof_pid=$!
6565

66+
logs_gathered=0
67+
gather_logs() {
68+
if((logs_gathered==1));then
69+
return
70+
fi
71+
logs_gathered=1
72+
73+
# Gather logs from all coderd and provisioner instances, and all workspaces.
74+
annotate_grafana"logs""Gather logs"
75+
podsraw="$(
76+
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-"
79+
)"
80+
mapfile -t pods<<<"${podsraw}"
81+
forpodin"${pods[@]}";do
82+
pod_name="${pod#pod/}"
83+
kubectl -n coder-big logs"${pod}" --since="${SCALETEST_RUN_START_TIME}">"${SCALETEST_LOGS_DIR}/${pod_name}.txt"
84+
done
85+
annotate_grafana_end"logs""Gather logs"
86+
}
87+
6688
set_appearance"${appearance_json}""${service_banner_color}""${service_banner_message} | Scaletest running: [${CODER_USER}/${CODER_WORKSPACE}](${CODER_URL}/@${CODER_USER}/${CODER_WORKSPACE})!"
6789

6890
# Show failure in the UI if script exits with error.
@@ -80,6 +102,10 @@ on_exit() {
80102
message_status=FAILED
81103
fi
82104

105+
# In case the test failed before gathering logs, gather them before
106+
# cleaning up, whilst the workspaces are still present.
107+
gather_logs
108+
83109
case"${SCALETEST_PARAM_CLEANUP_STRATEGY}"in
84110
on_stop)
85111
# Handled by shutdown script.
@@ -130,4 +156,7 @@ annotate_grafana "" "Start scaletest: ${SCALETEST_COMMENT}"
130156

131157
"${SCRIPTS_DIR}/run.sh"
132158

159+
# Gather logs before ending the test.
160+
gather_logs
161+
133162
"${SCRIPTS_DIR}/report.sh" completed

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp