Skip to content

Commit ead423e

Browse files
committed
fetch full coder binary
1 parent 0abd25b commit ead423e

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

cli/exp_scaletest_slim.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ func (r *RootCmd) scaletestCmd() *clibase.Cmd {
99
Use: "scaletest",
1010
Short: "Run a scale test against the Coder API",
1111
Handler: func(inv *clibase.Invocation) error {
12-
SlimUnsupported(inv.Stderr, "scaletest")
12+
SlimUnsupported(inv.Stderr, "exp scaletest")
1313
return nil
1414
},
1515
}

scaletest/lib/coder_init.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ ARCH="$(arch)"
2020
if [[ "$ARCH" == "x86_64" ]]; then
2121
ARCH="amd64"
2222
fi
23-
PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')"
2423

2524
if [[ -f "${CONFIG_DIR}/coder.env" ]]; then
2625
echo "Found existing coder.env in ${CONFIG_DIR}!"
@@ -29,8 +28,20 @@ if [[ -f "${CONFIG_DIR}/coder.env" ]]; then
2928
fi
3029

3130
maybedryrun "$DRY_RUN" mkdir -p "${CONFIG_DIR}"
32-
echo "Fetching Coder CLI for first-time setup!"
33-
maybedryrun "$DRY_RUN" curl -fsSLk "${CODER_URL}/bin/coder-${PLATFORM}-${ARCH}" -o "${CONFIG_DIR}/coder"
31+
echo "Fetching Coder for first-time setup!"
32+
pod=$(kubectl get pods \
33+
--namespace="${NAMESPACE}" \
34+
--selector="app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \
35+
--output="jsonpath='{.items[0].metadata.name}'")
36+
if [[ -z ${pod} ]]; then
37+
log "Could not find coder pod!"
38+
exit 1
39+
fi
40+
maybedryrun "$DRY_RUN" kubectl \
41+
--namespace="${NAMESPACE}" \
42+
cp \
43+
--container=coder \
44+
"${pod}:/opt/coder" "${CONFIG_DIR}/coder"
3445
maybedryrun "$DRY_RUN" chmod +x "${CONFIG_DIR}/coder"
3546

3647
set +o pipefail

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ SCALETEST_PPROF_DIR="${SCALETEST_RUN_DIR}/pprof"
2424
mkdir -p "${SCALETEST_STATE_DIR}" "${SCALETEST_RESULTS_DIR}" "${SCALETEST_PPROF_DIR}"
2525

2626
coder() {
27-
maybedryrun "${DRY_RUN}" command coder "${@}"
27+
if [[ -z "${SCALETEST_CODER_BINARY}" ]]; then
28+
echo "Fetching full coder binary..."
29+
fetch_coder_full
30+
echo "SCALETEST_CODER_BINARY=${SCALETEST_CODER_BINARY}"
31+
fi
32+
maybedryrun "${DRY_RUN}" "${SCALETEST_CODER_BINARY}" "${@}"
2833
}
2934

3035
show_json() {
@@ -240,3 +245,36 @@ set_appearance() {
240245
--data "${newjson}" \
241246
"${CODER_URL}/api/v2/appearance"
242247
}
248+
249+
# fetch_coder_full fetches the full (non-slim) coder binary from one of the coder pods
250+
# running in the same namespace as the current pod.
251+
fetch_coder_full() {
252+
local mkdir_dry_run_arg=""
253+
if [[ "${DRY_RUN}" == "1" ]]; then
254+
mkdir_dry_run_arg="--dry-run"
255+
fi
256+
target_dir=$(mktemp ${mkdir_dry_run_arg} --directory -t scaletest-coder-full-XXXXXX)
257+
target_path="${target_dir}/coder"
258+
local pod
259+
local namespace
260+
namespace=<(/var/run/secrets/kubernetes.io/serviceaccount/namespace)
261+
if [[ -z ${namespace} ]]; then
262+
log "Could not determine namespace!"
263+
exit 1
264+
fi
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}')
269+
if [[ -z ${pod} ]]; then
270+
log "Could not find coder pod!"
271+
exit 1
272+
fi
273+
maybedryrun "${DRY_RUN}" kubectl \
274+
--namespace "${namespace}" \
275+
cp \
276+
--container coder \
277+
"${pod}:/opt/coder" "${target_path}"
278+
maybedryrun chmod +x "${target_path}"
279+
export SCALETEST_CODER_BINARY="${target_path}"
280+
}

0 commit comments

Comments
 (0)