Skip to content

Commit 96100c0

Browse files
committed
allow more flexibility in cleanup
1 parent 806c73f commit 96100c0

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

scaletest/templates/scaletest-runner/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ data "coder_parameter" "cleanup_strategy" {
169169
}
170170
}
171171

172+
data "coder_parameter" "cleanup_prepare" {
173+
order = 14
174+
type = "bool"
175+
name = "Cleanup before scaletest"
176+
default = true
177+
description = "Cleanup existing scaletest users and workspaces before the scaletest starts (prepare phase)."
178+
mutable = true
179+
ephemeral = true
180+
}
181+
172182

173183
data "coder_parameter" "workspace_template" {
174184
order = 20
@@ -563,6 +573,7 @@ resource "coder_agent" "main" {
563573
SCALETEST_PARAM_NUM_WORKSPACES : data.coder_parameter.num_workspaces.value,
564574
SCALETEST_PARAM_CREATE_CONCURRENCY : "${data.coder_parameter.create_concurrency.value}",
565575
SCALETEST_PARAM_CLEANUP_STRATEGY : data.coder_parameter.cleanup_strategy.value,
576+
SCALETEST_PARAM_CLEANUP_PREPARE : data.coder_parameter.cleanup_prepare.value ? "1" : "0",
566577
SCALETEST_PARAM_LOAD_SCENARIOS : data.coder_parameter.load_scenarios.value,
567578
SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY : data.coder_parameter.load_scenario_run_concurrently.value ? "1" : "0",
568579
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_DURATION : "${data.coder_parameter.load_scenario_ssh_traffic_duration.value}",

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ if [[ $event = manual ]]; then
2121
fi
2222
fi
2323

24-
start_phase "Cleanup (${event})"
25-
coder exp scaletest cleanup \
26-
--cleanup-job-timeout 2h \
27-
--cleanup-timeout 5h |
28-
tee "${SCALETEST_RESULTS_DIR}/cleanup-${event}.txt"
29-
end_phase
24+
if [[ $event != shutdown_scale_down_only ]]; then
25+
start_phase "Cleanup (${event})"
26+
coder exp scaletest cleanup \
27+
--cleanup-job-timeout 2h \
28+
--cleanup-timeout 5h \
29+
| tee "${SCALETEST_RESULTS_DIR}/cleanup-${event}.txt"
30+
end_phase
31+
fi
3032

3133
if [[ $event != prepare ]]; then
32-
start_phase "Scaling down provisioners..."
34+
start_phase "Scale down provisioners"
3335
maybedryrun "$DRY_RUN" kubectl scale deployment/coder-provisioner --replicas 1
3436
maybedryrun "$DRY_RUN" kubectl rollout status deployment/coder-provisioner
37+
end_phase
3538
fi
3639

3740
if [[ $event = manual ]]; then

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ unset CODER_SESSION_TOKEN
4747
echo -n "${token}" >"${CODER_CONFIG_DIR}/session"
4848
[[ $VERBOSE == 1 ]] && set -x # Restore logging (if enabled).
4949

50-
log "Cleaning up from previous runs (if applicable)..."
51-
"${SCRIPTS_DIR}/cleanup.sh" "prepare"
50+
if [[ ${SCALETEST_PARAM_CLEANUP_PREPARE} == 1 ]]; then
51+
log "Cleaning up from previous runs (if applicable)..."
52+
"${SCRIPTS_DIR}/cleanup.sh" prepare
53+
fi
5254

5355
log "Preparation complete!"
5456

scaletest/templates/scaletest-runner/shutdown.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ trap cleanup EXIT
1414

1515
annotate_grafana "workspace" "Agent stopping..."
1616

17-
"${SCRIPTS_DIR}/cleanup.sh" shutdown
17+
shutdown_event=shutdown_scale_down_only
18+
if [[ ${SCALETEST_PARAM_CLEANUP_STRATEGY} == on_stop ]]; then
19+
shutdown_event=shutdown
20+
fi
21+
"${SCRIPTS_DIR}/cleanup.sh" "${shutdown_event}"
1822

1923
annotate_grafana_end "workspace" "Agent running"
2024

0 commit comments

Comments
 (0)