Skip to content

Commit d0fbd2c

Browse files
committed
improve cleanup
1 parent 569cfc1 commit d0fbd2c

File tree

1 file changed

+35
-18
lines changed
  • scaletest/templates/scaletest-runner/scripts

1 file changed

+35
-18
lines changed

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

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,49 @@ if [[ -z $event ]]; then
1212
event=manual
1313
fi
1414

15-
if [[ $event = manual ]]; then
16-
echo -n 'WARNING: This will clean up all scaletest resources, continue? (y/n) '
17-
read -r -n 1
18-
if [[ $REPLY != [yY] ]]; then
19-
echo $'\nAborting...'
20-
exit 1
21-
fi
22-
fi
23-
24-
if [[ $event != shutdown_scale_down_only ]]; then
15+
do_cleanup() {
2516
start_phase "Cleanup (${event})"
2617
coder exp scaletest cleanup \
2718
--cleanup-job-timeout 2h \
28-
--cleanup-timeout 5h \
29-
| tee "${SCALETEST_RESULTS_DIR}/cleanup-${event}.txt"
19+
--cleanup-timeout 5h |
20+
tee "${SCALETEST_RESULTS_DIR}/cleanup-${event}.txt"
3021
end_phase
31-
fi
22+
}
3223

33-
if [[ $event != prepare ]]; then
34-
start_phase "Scale down provisioners"
24+
do_scaledown() {
25+
start_phase "Scale down provisioners (${event})"
3526
maybedryrun "$DRY_RUN" kubectl scale deployment/coder-provisioner --replicas 1
3627
maybedryrun "$DRY_RUN" kubectl rollout status deployment/coder-provisioner
3728
end_phase
38-
fi
29+
}
30+
31+
case "${event}" in
32+
manual)
33+
echo -n 'WARNING: This will clean up all scaletest resources, continue? (y/n) '
34+
read -r -n 1
35+
if [[ $REPLY != [yY] ]]; then
36+
echo $'\nAborting...'
37+
exit 1
38+
fi
39+
40+
do_cleanup
41+
do_scaledown
3942

40-
if [[ $event = manual ]]; then
4143
echo 'Press any key to continue...'
4244
read -s -r -n 1
43-
fi
45+
;;
46+
prepare)
47+
do_cleanup
48+
;;
49+
shutdown)
50+
do_cleanup
51+
do_scaledown
52+
;;
53+
shutdown_scale_down_only)
54+
do_scaledown
55+
;;
56+
*)
57+
echo "Unknown event: ${event}" >&2
58+
exit 1
59+
;;
60+
esac

0 commit comments

Comments
 (0)