diff --git a/cli/exp_scaletest.go b/cli/exp_scaletest.go index 8c7a3ae427e01..5b8da2713fa40 100644 --- a/cli/exp_scaletest.go +++ b/cli/exp_scaletest.go @@ -1,3 +1,5 @@ +//go:build !slim + package cli import ( diff --git a/cli/exp_scaletest_slim.go b/cli/exp_scaletest_slim.go new file mode 100644 index 0000000000000..d9ccd325e5ccd --- /dev/null +++ b/cli/exp_scaletest_slim.go @@ -0,0 +1,18 @@ +//go:build slim + +package cli + +import "github.com/coder/coder/v2/cli/clibase" + +func (r *RootCmd) scaletestCmd() *clibase.Cmd { + cmd := &clibase.Cmd{ + Use: "scaletest", + Short: "Run a scale test against the Coder API", + Handler: func(inv *clibase.Invocation) error { + SlimUnsupported(inv.Stderr, "exp scaletest") + return nil + }, + } + + return cmd +} diff --git a/scaletest/lib/coder_init.sh b/scaletest/lib/coder_init.sh index c3b322e6c47a0..f8c905958ece4 100755 --- a/scaletest/lib/coder_init.sh +++ b/scaletest/lib/coder_init.sh @@ -20,7 +20,6 @@ ARCH="$(arch)" if [[ "$ARCH" == "x86_64" ]]; then ARCH="amd64" fi -PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')" if [[ -f "${CONFIG_DIR}/coder.env" ]]; then echo "Found existing coder.env in ${CONFIG_DIR}!" @@ -29,8 +28,20 @@ if [[ -f "${CONFIG_DIR}/coder.env" ]]; then fi maybedryrun "$DRY_RUN" mkdir -p "${CONFIG_DIR}" -echo "Fetching Coder CLI for first-time setup!" -maybedryrun "$DRY_RUN" curl -fsSLk "${CODER_URL}/bin/coder-${PLATFORM}-${ARCH}" -o "${CONFIG_DIR}/coder" +echo "Fetching Coder for first-time setup!" +pod=$(kubectl get pods \ + --namespace="${NAMESPACE}" \ + --selector="app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \ + --output="jsonpath='{.items[0].metadata.name}'") +if [[ -z ${pod} ]]; then + log "Could not find coder pod!" + exit 1 +fi +maybedryrun "$DRY_RUN" kubectl \ + --namespace="${NAMESPACE}" \ + cp \ + --container=coder \ + "${pod}:/opt/coder" "${CONFIG_DIR}/coder" maybedryrun "$DRY_RUN" chmod +x "${CONFIG_DIR}/coder" set +o pipefail diff --git a/scaletest/templates/scaletest-runner/scripts/lib.sh b/scaletest/templates/scaletest-runner/scripts/lib.sh index ec94e952fda3c..57c96e091c4e6 100644 --- a/scaletest/templates/scaletest-runner/scripts/lib.sh +++ b/scaletest/templates/scaletest-runner/scripts/lib.sh @@ -20,11 +20,17 @@ SCALETEST_PHASE_FILE="${SCALETEST_STATE_DIR}/phase" # shellcheck disable=SC2034 SCALETEST_RESULTS_DIR="${SCALETEST_RUN_DIR}/results" SCALETEST_PPROF_DIR="${SCALETEST_RUN_DIR}/pprof" +# https://github.com/kubernetes/kubernetes/issues/72501 :-( +SCALETEST_CODER_BINARY="/tmp/coder-full-${SCALETEST_RUN_ID//:/-}" mkdir -p "${SCALETEST_STATE_DIR}" "${SCALETEST_RESULTS_DIR}" "${SCALETEST_PPROF_DIR}" coder() { - maybedryrun "${DRY_RUN}" command coder "${@}" + if [[ ! -x "${SCALETEST_CODER_BINARY}" ]]; then + log "Fetching full coder binary..." + fetch_coder_full + fi + maybedryrun "${DRY_RUN}" "${SCALETEST_CODER_BINARY}" "${@}" } show_json() { @@ -240,3 +246,36 @@ set_appearance() { --data "${newjson}" \ "${CODER_URL}/api/v2/appearance" } + +# fetch_coder_full fetches the full (non-slim) coder binary from one of the coder pods +# running in the same namespace as the current pod. +fetch_coder_full() { + if [[ -x "${SCALETEST_CODER_BINARY}" ]]; then + log "Full Coder binary already exists at ${SCALETEST_CODER_BINARY}" + return + fi + local pod + local namespace + namespace=$(