Skip to content

feat(scaletest): annotate scaletest pod when scaletest is in progress #10235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address PR feedback
  • Loading branch information
johnstcn committed Oct 12, 2023
commit 8ed96d565a8185c42c2428c1d9f07aa049d3feaa
29 changes: 14 additions & 15 deletions scaletest/templates/scaletest-runner/scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ show_json() {
set_status() {
dry_run=
if [[ ${DRY_RUN} == 1 ]]; then
dry_run=" (dry-ryn)"
dry_run=" (dry-run)"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by 😁

fi
prev_status=$(get_status)
if [[ ${prev_status} != *"Not started"* ]]; then
Expand All @@ -49,6 +49,9 @@ set_status() {
echo "$(date -Ins) ${*}${dry_run}" >>"${SCALETEST_STATE_DIR}/status"

annotate_grafana "status" "Status: ${*}"

status_lower=$(tr '[:upper:]' '[:lower:]' <<<"${*}")
set_pod_status_annotation "${status_lower}"
}
lock_status() {
chmod 0440 "${SCALETEST_STATE_DIR}/status"
Expand Down Expand Up @@ -248,17 +251,13 @@ set_appearance() {
}

namespace() {
local ns
ns=$(</var/run/secrets/kubernetes.io/serviceaccount/namespace)
echo "${ns}"
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace
}
coder_pods() {
local pods
pods=$(kubectl get pods \
kubectl get pods \
--namespace "$(namespace)" \
--selector "app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \
--output jsonpath='{.items[*].metadata.name}')
echo "${pods}"
--output jsonpath='{.items[*].metadata.name}'
}

# fetch_coder_full fetches the full (non-slim) coder binary from one of the coder pods
Expand All @@ -271,18 +270,18 @@ fetch_coder_full() {
ns=$(namespace)
if [[ -z "${ns}" ]]; then
log "Could not determine namespace!"
exit 1
return
fi
log "Namespace from serviceaccount token is ${ns}"
pods=$(coder_pods)
if [[ -z ${pods} ]]; then
log "Could not find coder pods!"
exit 1
return
fi
pod=$(echo "${pods}" | cut -d ' ' -f 1)
pod=$(cut -d ' ' -f 1 <<<"${pods}")
if [[ -z ${pod} ]]; then
log "Could not find coder pod!"
exit 1
return
fi
log "Fetching full Coder binary from ${pod}"
# We need --retries due to https://github.com/kubernetes/kubernetes/issues/60140 :(
Expand All @@ -296,12 +295,12 @@ fetch_coder_full() {
log "Full Coder binary downloaded to ${SCALETEST_CODER_BINARY}"
}

# set_status_annotation annotates the currently running pod with the key
# set_pod_status_annotation annotates the currently running pod with the key
# com.coder.scaletest.status. It will overwrite the previous status.
set_status_annotation() {
set_pod_status_annotation() {
if [[ $# -ne 1 ]]; then
log "must specify an annotation value"
exit 1
return
else
maybedryrun "${DRY_RUN}" kubectl --namespace "$(namespace)" annotate pod "$(hostname)" "com.coder.scaletest.status=$2" --overwrite
fi
Expand Down
1 change: 0 additions & 1 deletion scaletest/templates/scaletest-runner/scripts/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ mkdir -p "${SCALETEST_RESULTS_DIR}"

log "Preparing scaletest workspace environment..."
set_status Preparing
set_status_annotation preparing

log "Compressing previous run logs (if applicable)..."
mkdir -p "${HOME}/archive"
Expand Down
2 changes: 0 additions & 2 deletions scaletest/templates/scaletest-runner/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export SCALETEST_PARAM_LOAD_SCENARIOS=("${scaletest_load_scenarios[@]}")

log "Running scaletest..."
set_status Running
set_status_annotation running

start_phase "Creating workspaces"
coder exp scaletest create-workspaces \
Expand Down Expand Up @@ -64,4 +63,3 @@ done

log "Scaletest complete!"
set_status Complete
set_status_annotation completed